Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/133731-cron-job/
Share on other sites

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/133731-cron-job/#findComment-695941
Share on other sites

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??

Link to comment
https://forums.phpfreaks.com/topic/133731-cron-job/#findComment-695945
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.