could someone tell me what am i doing wrong?
i would like to run a script (script.php) every minute (eventually once a day) using cron. the script is under a folder called auto. i edited crontab and this is how it appears...
1 /usr/local/lib/php /path/to/script/auto/script.php
it still wont work! thanks.
Did you use crontab -e or edit the file directly? If you do crontab -l at the command line does your line appear? if you run /usr/loca/lib/php /path/to/script/auto/script.php from the command line does it run? You could try a really simple script just to set it
#!/bin/bash date >> output
whack this in your crontab (using crontab -e) and then tail -f output to see if the time is being added every minute or not? HTH Bubble
yes that's how it appears bu it give me no file or directory. how do i run the code you gave?
when i do:
/path/to/script/auto/script.php
it gives me permission denied!
Put the script code above into a file and then at the command line type crontab -e When you're in the editor you should see your crontab line, delete it and replace it with
1 * * * * /path/to/file
and then exit the editor. You can then type
tail -f output
at the command line to "follow" what's being added to the output file. Leave it for a little while and see if anything's being added to it. HTH Bubble
do you mean put the script above on my script.php?
No, put the code in a file of it's own, it's not php it's a bash script which appends a date/time string to the end of a file called output. If this file does not exists it will create it. This is purely some test code to try and iscolate where the problem is.
sorry for being so dumb, but where do i put the file with
#!/bin/bash date >> output [/code]
how do i name it?
it doesn't matter what you call it or where you put it so long as make sure the line you add into the crontab (with crontab -e) runs it. I've just noticed a little change which needs to be made to the script.
#!/bin/bash date >> /absolute/path/to/output
You need to give the output file an absolute path (probably just to your home directory somewhere) .
i dont know id i did it right. i am using putty to have shell access. after the username and password i typed:
date >> output
then crontab -e putting
path/to/script/auto/script.php
saved it then
i get
Tue May 18 08:16:08 EDT 2004!
Did you just put path/to/script/auto/script.php with not *s orr numbers before it? It should have caused an error.
If you have added it correctly and you leave tail going (it will appear to just hang but it's just waiting for more to be appended to the file) it should display more date every minute. If it does not something has gone wrong.
I just re-read your post. I'll explain this in step by step instructions.
Login with PuTTy
Open your favourite text editor
Type the following
replacing /absolute/path/to/output with wherever you want the output file to be
Save the file (for ease of explaining I'm going say you saved it to /path/to/file but it could be to anywhere)
Exit the text editor
Type
crontab -e
at the command line
Replace whatever is there with
* * * * * /path/to/file
replacing /path/to/file with the path used in step 4.
Save and Exit
tail -f
at the command line and wait. [/list=1] I'm sorry, a couple of my previous posts were slightly erroneous HTH Bubble
i followed everything. after tail -f nothing happens!
i think i figured out something. i do crontab -l and this is how it looks like.
5 /usr/local/lib/php4 /path/to/script/auto/script.php
this should execute script.php every 5 minutes. when i type
/usr/local/lib/php4 /path/to/script/auto/script.php
via shell access the script works. but the cronjob doesn't work!!!
any idea?
5 is NOT every five minutes, it's 5 minutes past every hour to do every five minutes you either need 0,5,10,15,20,25,30,35,40,45,50,55 or on some versions simply 5/ *
HTH Bubble
5/* * * * * "lynx -source [url]http://example.com/script.php[/url] > /dev/null"
Or even
5/* * * * * "usr/local/lib/php4 /path/to/script/auto/script.php > /dev/null"
Notice the quotes around the command. Not always required though.
the cron works now! thanks for all the help!