Peggy Posted October 15, 2009 Share Posted October 15, 2009 So I've figured out alot about how to automatically run a php function. I can't figure out where to put the CRON code do I put it in the header between the head tags? do I put it before any html code? Am I right in assuming that All I have to do is --put it in the right place-- then upload it to the server. Also I have to put executable permissions on the delete_old_count.php I have this set for 11:30 tonight. (as a test). #!/usr/local/bin/php -q 30 23 15 10 * auto_functions/delete_old_count.php Link to comment https://forums.phpfreaks.com/topic/177835-where-do-i-put-cron-code/ Share on other sites More sharing options...
trq Posted October 15, 2009 Share Posted October 15, 2009 There shouldn't be any html code within any cron job, its not like its going to get displayed to anyone. Link to comment https://forums.phpfreaks.com/topic/177835-where-do-i-put-cron-code/#findComment-937688 Share on other sites More sharing options...
trq Posted October 15, 2009 Share Posted October 15, 2009 On top of that, you can put the script whereever you like, you just need to tell cron where it is. eg; 30 23 15 10 * /path/to/delete_old_count.php Also, the shebang (#!/usr/local/bin/php -q ) goes within your php script, not your crontab file. Link to comment https://forums.phpfreaks.com/topic/177835-where-do-i-put-cron-code/#findComment-937690 Share on other sites More sharing options...
Peggy Posted October 15, 2009 Author Share Posted October 15, 2009 okay please excuse me for being a little slow. I put this code: 30 23 15 10 * auto_functions/delete_old_count.php on a separate page with the extension of what? Or do I stick it on an existing page? Sorry I don't get it. Also this code: #!/usr/local/bin/php -q goes on the page delete_old_count.php Does it go at the top of the page before the php tags? Link to comment https://forums.phpfreaks.com/topic/177835-where-do-i-put-cron-code/#findComment-937700 Share on other sites More sharing options...
trq Posted October 15, 2009 Share Posted October 15, 2009 I put this code: 30 23 15 10 * auto_functions/delete_old_count.php on a separate page with the extension of what? Or do I stick it on an existing page? Sorry I don't get it. That is not code, it is simply a cron directive. It needs to go within your crontab file. You can access this file by issuing... crontab -e to the terminal. Then yes, the shbang line needs to be the very first line within your script. it tells the shell what program to use to execute the script. linux doesn't care about file extensions. Link to comment https://forums.phpfreaks.com/topic/177835-where-do-i-put-cron-code/#findComment-937705 Share on other sites More sharing options...
Peggy Posted October 15, 2009 Author Share Posted October 15, 2009 I guess I still don't get it. Is a crontab file a file that exists on the server already like the php.ini Also I don't understand what you mean by: issuing... Link to comment https://forums.phpfreaks.com/topic/177835-where-do-i-put-cron-code/#findComment-937714 Share on other sites More sharing options...
trq Posted October 15, 2009 Share Posted October 15, 2009 Cron is a program on linux. To use it, you need to put directives within your crontab file. To get access to this crontab file you need to type... crontab -e into a terminal/shell and hit enter. Link to comment https://forums.phpfreaks.com/topic/177835-where-do-i-put-cron-code/#findComment-937716 Share on other sites More sharing options...
Peggy Posted October 15, 2009 Author Share Posted October 15, 2009 Thank-you for your help. I'm kind of new at this. I actually figured out that I could log into my Godaddy account and access the CRON from there. Link to comment https://forums.phpfreaks.com/topic/177835-where-do-i-put-cron-code/#findComment-937744 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.