gevans Posted November 22, 2008 Share Posted November 22, 2008 Hey Guys, I know I should shove this in an open forum but I have more faith in you guys... I know what a cron job is capable of and what it's used for but have never used or set one up... Does any one know of any good facilities? I want to know how to write a cron job and where to set it (server root etc...) cheers Quote Link to comment https://forums.phpfreaks.com/topic/133731-cron-job/ Share on other sites More sharing options...
MasterACE14 Posted November 22, 2008 Share Posted November 22, 2008 If you have a Cpanel for your webhosting, then the cron section would be in there(if the webhost has crons) this is on the wikipedia for cron: # +---------------- minute (0 - 59) # | +------------- hour (0 - 23) # | | +---------- day of month (1 - 31) # | | | +------- month (1 - 12) # | | | | +---- day of week (0 - 6) (Sunday=0 or 7) # | | | | | * * * * * command to be executed Basically, a cron is set with 5 parameters. a asterix means 'every' , so a asterix in the minute column means 'every minute'. Something like this. 1 * * * * will make the cron run on the first minute of every hour, of every day, of every month. Once you worked out what times the cron will be run. You then need to set the command for the cron. something like.. php /home/someuser/mywebsite/phpfile.php You put 'php' before the path to the PHP file you want to execute. (if you want to execute a php file) So your full cron command would look like: 1 * * * * php /home/someuser/mywebsite/phpfile.php I hope this helps. Just look for the cron section in your Cpanel, if you have Cpanel, and if there is crons. Then it will have the fields where you can put in your command. Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/133731-cron-job/#findComment-695941 Share on other sites More sharing options...
gevans Posted November 22, 2008 Author Share Posted November 22, 2008 Thanks, that was a good insight. I use a resellers hosting package through my hosts that doesn't include cpanel, they do a cron job equivalent but dont call it a cron job, it probably is though.... Does this line (the cron command) go into its own file, and what would the file be called?? Quote Link to comment https://forums.phpfreaks.com/topic/133731-cron-job/#findComment-695945 Share on other sites More sharing options...
MasterACE14 Posted November 22, 2008 Share Posted November 22, 2008 I'm not sure, I've only ever used crons either through my webhosting Cpanel, or through my localhost with cron.exe which is just runs as a background process Quote Link to comment https://forums.phpfreaks.com/topic/133731-cron-job/#findComment-695965 Share on other sites More sharing options...
gevans Posted November 22, 2008 Author Share Posted November 22, 2008 Ok, no worries. I've just had a cron job working from my server so not a big issue, might have a look round tomorrow see if I can figure it out. Quote Link to comment https://forums.phpfreaks.com/topic/133731-cron-job/#findComment-695968 Share on other sites More sharing options...
zq29 Posted November 24, 2008 Share Posted November 24, 2008 For instructions on editing your crontab, fire up a CLI and... man crontab or just edit it with... crontab -e using the format outlined above by MasterACE14 Quote Link to comment https://forums.phpfreaks.com/topic/133731-cron-job/#findComment-698005 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.