jester626 Posted October 26, 2007 Share Posted October 26, 2007 I am trying to run a PHP Script in a crontab. I have added: #!/usr/local/bin/php -q at the top of the php page/script. I have also set up the crontab as follows: 00 40 * * * /var/www/the/rest/of/the/path/file.php This should run the script everyday at 00:40. But to no avail. I am using PHP 5.1.6 Any help would be appreciated Jester Quote Link to comment https://forums.phpfreaks.com/topic/74835-run-a-php-script-in-crontab/ Share on other sites More sharing options...
MasterACE14 Posted October 26, 2007 Share Posted October 26, 2007 I had the same problem, theirs an easy way to fix this and get the cronjob running. change this: 00 40 * * * /var/www/the/rest/of/the/path/file.php to this: 00 40 * * * php /var/www/the/rest/of/the/path/file.php Note: you must have a space after the php Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/74835-run-a-php-script-in-crontab/#findComment-378402 Share on other sites More sharing options...
jester626 Posted October 26, 2007 Author Share Posted October 26, 2007 What did you use as the first line of your php file? Did you use #!/usr/local/bin/php -q ? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/74835-run-a-php-script-in-crontab/#findComment-378405 Share on other sites More sharing options...
phpQuestioner Posted October 26, 2007 Share Posted October 26, 2007 I hate to impose on this thread with a question, but you guys are talking about what I am interested in creating too. I want to be able to create a cron; but I do not have a c-panel on my web host. I tried to open up a notepad file and ad some cron code to it and save it with a ".cron" extension, but this did not work. I do not know anything about crons except what I have been reading about for the past hour. How can I create a cron without c-panel and what extension should I save it as? Is there any thing special I need to set up with my web host to make crons work? Here is the code I put in the text file that I first spoke of. 15 * * * * /usr/local/bin/php -q /10-26-2007.php I found this code and tried it, but it did not work - any suggestions or answers would be awesome. Quote Link to comment https://forums.phpfreaks.com/topic/74835-run-a-php-script-in-crontab/#findComment-378407 Share on other sites More sharing options...
MasterACE14 Posted October 26, 2007 Share Posted October 26, 2007 What did you use as the first line of your php file? Did you use #!/usr/local/bin/php -q ? Thanks you don't need anything in the file you are running in the cron, it runs fine without it. I hate to impose on this thread with a question, but you guys are talking about what I am interested in creating too. I want to be able to create a cron; but I do not have a c-panel on my web host. I tried to open up a notepad file and ad some cron code to it and save it with a ".cron" extension, but this did not work. I do not know anything about crons except what I have been reading about for the past hour. How can I create a cron without c-panel and what extension should I save it as? Is there any thing special I need to set up with my web host to make crons work? Here is the code I put in the text file that I first spoke of. 15 * * * * /usr/local/bin/php -q /10-26-2007.php I found this code and tried it, but it did not work - any suggestions or answers would be awesome. I don't know if its possible to run cronjobs without cron in C-panel, I've never heard of it done any other way sorry :-\ Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/74835-run-a-php-script-in-crontab/#findComment-378409 Share on other sites More sharing options...
phpQuestioner Posted October 26, 2007 Share Posted October 26, 2007 ok - if I cannot not run crons without C-Panel; is there any way to automate a php script? another member of this forum suggested ajax, but I thought that ajax had to always be executed by client side events. is there a way to automate a php script with ajax; without any interaction with ajax/php script (totally automated timed events - like cronjobs)? Quote Link to comment https://forums.phpfreaks.com/topic/74835-run-a-php-script-in-crontab/#findComment-378412 Share on other sites More sharing options...
jester626 Posted October 26, 2007 Author Share Posted October 26, 2007 Do you have shell access to your webhost? Meaning can you access it through a terminal window (such as putty)? If you can access your host via a terminal window then you can try and see if it will let you do a "cron -e" This may or may not work depending how your hosting provider has configured the domains. I would suggest you contacting them and asking them if it is possible. Hope this helps, Jester Quote Link to comment https://forums.phpfreaks.com/topic/74835-run-a-php-script-in-crontab/#findComment-378413 Share on other sites More sharing options...
phpQuestioner Posted October 26, 2007 Share Posted October 26, 2007 Thank For The Help jester626 And MasterACE14 I am only able to access my files directly through my web host file manager (not really like a terminal window software; it's built right into a web page - not really much of a control panel - very basic stuff - may have to upgrade sometime to accomplish cronjobs). Quote Link to comment https://forums.phpfreaks.com/topic/74835-run-a-php-script-in-crontab/#findComment-378415 Share on other sites More sharing options...
MasterACE14 Posted October 26, 2007 Share Posted October 26, 2007 ok - if I cannot not run crons without C-Panel; is there any way to automate a php script? another member of this forum suggested ajax, but I thought that ajax had to always be executed by client side events. is there a way to automate a php script with ajax; without any interaction with ajax/php script (totally automated timed events - like cronjobs)? their is a PHP function that was suggested to me a while back, called "sleep()" and "usleep()" , look them up at php.net , that could possibly work. Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/74835-run-a-php-script-in-crontab/#findComment-378424 Share on other sites More sharing options...
DyslexicDog Posted October 26, 2007 Share Posted October 26, 2007 ok - if I cannot not run crons without C-Panel; is there any way to automate a php script? another member of this forum suggested ajax, but I thought that ajax had to always be executed by client side events. is there a way to automate a php script with ajax; without any interaction with ajax/php script (totally automated timed events - like cronjobs)? Create the script on your host and call it from another computer using some kind of scheduler? Quote Link to comment https://forums.phpfreaks.com/topic/74835-run-a-php-script-in-crontab/#findComment-378707 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.