UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 11th, 2002, 09:56 AM
mikeShank mikeShank is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Philadelphia
Posts: 239 mikeShank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 20 sec
Reputation Power: 8
Send a message via AIM to mikeShank
running script with crontab

Im trying to execute a php file with cron that will email me every minute(just for testing), but can't for some reason, these are the 2 crontabs i've tried from some examples but they aren't executing. Any ideas, i've never used cron before, but from what i've read it's not much more complicated than what i have

crontab:
* * * * * lynx -dump http://www.abc.com/testcron.php
or
* * * * * /usr/local/www/htdocs/testcron.php

testcron.php:
PHP Code:
 mail("me@abc.com","test","this is a test"); 

Reply With Quote
  #2  
Old November 11th, 2002, 12:14 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 184
where you have asterisks you tell cron when to execute the line. pobably any time, any minute, any second is not valid

this is the order and meaning of the 5 values and their range (taken from FreeBSDīs man pages):
Quote:
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)


also maybe the path is not set, so you need to supply the full path to lynx.
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #3  
Old November 11th, 2002, 02:51 PM
Tzicha's Avatar
Tzicha Tzicha is offline
Here, not there
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 312 Tzicha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 36 sec
Reputation Power: 7
Additionally, with the second attempt
PHP Code:
* * * * * /usr/local/www/htdocs/testcron.php 

you need to make certain that testcron.php is executable from the command line. What happens when you run testcron.php from the commandline? If it doesn't work then you need to read documents such as http://www.devarticles.com/art/1/231

Reply With Quote
  #4  
Old November 11th, 2002, 04:10 PM
davetufts davetufts is offline
-------------------
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 200 davetufts User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 56 sec
Reputation Power: 9
Quote:
* * * * * lynx -dump http://www.abc.com/testcron.php


What you have listed in your first example is correct. You may, however, need to specify the full path to lynx (the cron daemon may not know where 'lynx' is). From the command line, try 'whereis lynx', and use the output in your crontab:
* * * * * /usr/local/bin/lynx -dump http://www.abc.com/testcron.php

And just to make sure that the php page is not the problem, hit your 'testcron' page manually (by using the same command in your teminal window: "/path/to/lynx -dump...") and make sure that you get the mail.

Reply With Quote
  #5  
Old November 11th, 2002, 07:31 PM
mikeShank mikeShank is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Philadelphia
Posts: 239 mikeShank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 20 sec
Reputation Power: 8
Send a message via AIM to mikeShank
thanks everyone

Reply With Quote
  #6  
Old November 13th, 2002, 08:40 AM
mikeShank mikeShank is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Philadelphia
Posts: 239 mikeShank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 20 sec
Reputation Power: 8
Send a message via AIM to mikeShank
I've executed both from the command line:
/usr/local/bin/lynx -dump http://www.abc.com/testcron.php
and
lynx -dump http://www.abc.com/testcron.php

and both executed.

but using my crontab:
* * * * * /usr/local/bin/lynx -dump http://www.abc.com/testcron.php
or
1 * * * * /usr/local/bin/lynx -dump http://www.abc.com/testcron.php

neither would execute. I'm stumped

Reply With Quote
  #7  
Old November 13th, 2002, 11:46 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 184
... btw this is off-topic, this is the php forum. this discussion should be moved to the linux forum (iīll ask the mod, wait...).

are you using linux? which distribution?

maybe there is some other problem.
- did you check if cron is running at all? ("ps ax|grep cron")
- did you read the logs? (/var/log/cron or /var/log/messages)

Reply With Quote
  #8  
Old November 13th, 2002, 01:55 PM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,385 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 21 h 10 m 45 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
Well, it's half on topic and can be an issue that people run into when trying to schedule a PHP script to run through cron.

So you say that those lines work from the command line, but they don't work in cron, right? What are all of the steps you're doing to add this line to your cron? If I remember correctly, there are a couple steps involved to get this going. Or, like someone else said, is cron even running?

---John Holmes...

Reply With Quote
  #9  
Old November 13th, 2002, 02:18 PM
mikeShank mikeShank is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Philadelphia
Posts: 239 mikeShank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 20 sec
Reputation Power: 8
Send a message via AIM to mikeShank
Hi John,
I login to my server thru telnet do the following command:
crontab /path/to/my/crontab

then to check it:
crontab -l
this shows me the contents of my crontab

and as far as testing to see if cron was running, I used
Quote:
- did you check if cron is running at all? ("ps ax|grep cron")

and this was the response:

70850 ?? IsJ 0:47.73 cron
71611 p6 S+J 0:00.00 grep cron

i have no idea if that means yes or no.

Reply With Quote
  #10  
Old November 14th, 2002, 12:51 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 184
this means yes, it is running

did you find the log files? (i looked, mine go to /var/log/cron, but maybe i set this up...)

Reply With Quote
  #11  
Old November 14th, 2002, 07:24 AM
mikeShank mikeShank is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Philadelphia
Posts: 239 mikeShank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 20 sec
Reputation Power: 8
Send a message via AIM to mikeShank
I found and checked the /var/log/cron file and there weren't any entries referring to my crontab. Where would i find errors if there were any trying to run a crontab?

Reply With Quote
  #12  
Old November 14th, 2002, 09:29 AM
davetufts davetufts is offline
-------------------
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 200 davetufts User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 56 sec
Reputation Power: 9
This is pretty much off-topic for the PHP list now, but try add this line to your crontab:

* * * * * date >> /your/home/dir/cron.txt

(replace /your/home/dir/ with the full path to your home directory)
Let it run a couple minutes then check if it created a file called 'cron.txt' that has a bunch of dates in it...

Reply With Quote
  #13  
Old November 14th, 2002, 09:33 AM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,385 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 21 h 10 m 45 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
Yes, it is now.

Reply With Quote
  #14  
Old November 14th, 2002, 11:54 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 184
mikeShank, you can find all error messages concerning cron like this:

grep -iR "cron" /var/log

(grep: case insensitive, Recursive)

Reply With Quote
  #15  
Old December 4th, 2005, 01:24 PM
dstonek's Avatar
dstonek dstonek is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Uruguay
Posts: 269 dstonek User rank is Corporal (100 - 500 Reputation Level)