Results 1 to 7 of 7
Hello
I'm new in linux and want to make cron job for php page
Every day at 12 am how can i do that?...
- 06-02-2011 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 11
cron job
Hello
I'm new in linux and want to make cron job for php page
Every day at 12 am how can i do that?
- 06-02-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,813
not sure what you mean about the php part, but as to cron, something like this would work:
you'd enter the above example code into the STDIN of the following commandCode:0 0 * * * /tmp/my_php_script.sh > /tmp/cronjob.log 2>&1
When you're done editing the file, use the key sequence :wq to save the file and get out. When you're done, use this to check your work:Code:crontab -e
Make sure crond is running (ps auxww|grep crond), then after midnite, check for the output of the script in /tmp/cronjob.log. In order to test that it is working, make the cronjob run every minute or something. see more on setting cron times with:Code:crontab -l
You can also check crond's log, /var/log/cron, for help in seeing what cron is doing.Code:man 5 crontab
If you give more details on the php part, i'm sure someone here can help you w/that.
- 06-02-2011 #3Just Joined!
- Join Date
- Oct 2009
- Posts
- 11
cron already installed but i don't know how to run php script
- 06-02-2011 #4Linux Guru
- Join Date
- May 2011
- Posts
- 1,813
ah, so you mean you want to run a php script that is being hosted on a website?
how about:
is that what you mean?Code:wget -O test-output.php http://myserver/myscript.php
- 06-02-2011 #5Just Joined!
- Join Date
- Oct 2009
- Posts
- 11
yes i have php script to send email and i want to run it every Friday at midnight
- 06-02-2011 #6Linux Guru
- Join Date
- May 2011
- Posts
- 1,813
but i assume the script is run via a webpage hosted on a webserver, yes? How do you run and test it yourself?
does it require any user input at the page, and then the click of a button, for example? If so, then you'll need to do some modifying of the php script to make it run in an automated fashion (either by hard-coding variables or making the script accept parameters that you can pass via as query string variables to it in the URL).
If it doesn't require any input, then the previous wget command should have worked.
- 06-04-2011 #7Just Joined!
- Join Date
- Oct 2009
- Posts
- 11
thanks for your reply
I used this command and it work good
Code:30 5 * * * wget url/mail.php


Reply With Quote
