Portal Home > Knowledgebase > Articles Database > execute php script via cron, on VDS
execute php script via cron, on VDS
Posted by yaba, 08-24-2006, 11:10 PM |
Hello all,
I'm with Jumpline at the moment, on a VDS plan.
I'm trying to execute a PHP script via cron, but haven't managed so far. What I've tried is:
-edit the cronjobs file (/var/spool/cron/account_name) via SSH (so line terminations etc should be ok).
-added the cronjob lines as explained below.
-made sure I left a blank line at the end.
-started/reloaded the demon using "crontab" (no parameters are needed under a VDS environment)
The lines I've tried are:
35 * * * * php /path/to/script.php
35 * * * * php -f /path/to/script.php
35 * * * * /bin/php /path/to/script.php
35 * * * * /bin/php -f /path/to/script.php
none of which worked.
Could someone help a newbie please?
Thanks for reading...
P.S. I've submitted a ticket to JL for this, and they answered "sorry, we do not provide support for cron" :/
|
Posted by andreyka, 08-25-2006, 03:37 AM |
You don't edit cron file directly! Use crontab -u user intead
Also you may be forgot cd to current directory or php in diffirent localtion.
|
Posted by A-Wing, 08-25-2006, 04:01 AM |
Check your cron log also, logs are your friend
The cron log is usually /var/log/cron or similar. You can check the latest entries by running 'tail /var/log/cron'
Good luck
|
Posted by firestarter, 08-25-2006, 04:46 AM |
Use the full path of your php binary. You can get the full path of your php binary by running the "which php"
Use /path/to/php -q /path/to/script
Then change the crons accordingly. Make sure that the php file have correct permissions set to it.
|
Posted by A-Wing, 08-25-2006, 04:55 AM |
Or you could add at the top of your script:
#!/usr/bin/php -q
(assuming that is where php is)
Make it executable and then just use /path/to/script
|
Posted by yaba, 08-25-2006, 12:27 PM |
usr/bin/php -q /path/to/script.php
This worked. Don't know if it was the path (as the other is supposed to be working too when I run it from command line), or the -q switch, and don't really have the courage to find out
Thanks everyone who replied, and specially firestarter
|
Posted by firestarter, 08-27-2006, 01:20 AM |
You are most welcome.
Glad that it helped.
|
Posted by entertainz, 04-16-2008, 07:30 AM |
yaba
I am also newbie for cron job.
I have VDS with jumpline.
I want to set cron job with my jumpline account.
Can you explain the whole point from very first to final.
Suppose, If I want to execute this page every every 3 minutes.
http : / / livewebs.info / submit.php ... what should I do?
Thanks in advance.
|
Posted by david510, 04-16-2008, 07:42 AM |
Use below.
*/3 * * * * /usr/bin/php /path/to/phpfile > /dev/null 2>&1
|
Posted by entertainz, 04-16-2008, 08:44 AM |
No, It's not working yet.
which path should I specify instead of /path/to/phpfile if I want to fire url "http : // livewebs . info/submit.php"
Is it compulsory to restart my VDS after changes?
|
Add to Favourites Print this Article
Also Read