PHP Cron Jobs

Status
Not open for further replies.

xSnipez

New Member
Messages
18
Reaction score
0
Points
1
So, I've seen a thread on this before, but couldn't understand the directory stuff and the command. Could someone help me out if I'm using php and the cron file is in the public_html directory please?
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
This Cron job will make a 'output' log file in your [ public_html ] folder and assumes you PHP script is in your [ public_html ] folder
to test - set the 'time' for every six (6) minutes - I suggest setting it to run no more frequently than you will actually need - after the test
Code:
Minute -- */6
Hour ---- *
Day ----- *
Month --- *
Weekday --*

replace {your cPanel name} and {your PHP file name} with yours - without the "{" "}" - do not add any spaces

Cron command:
/usr/local/bin/php /home/{your cPanel name}/public_html/{your PHP file name} 2>&1 >> /home/{your cPanel name}/public_html/cron_output.log
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
cPanel first page
Left column "Stats"
Second entry, "Home Directory" , /home/your-cPanel-name
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
You're not allowed a one-minute cron. You are not allowed to run a cron more than once every five minutes (which means that if you have multiple crons, you have to schedule them so that they don't run less than five minutes apart).
 

xSnipez

New Member
Messages
18
Reaction score
0
Points
1
So say if I wanted to run a hospital cron, I'd have to run it every 5 minutes?
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
you must not have more than 1 running (starting) - no less than - every 5 minutes
....can NOT have two (2) or more running at the same time
 

xSnipez

New Member
Messages
18
Reaction score
0
Points
1
All this confuses me.

I have a 1 minute cron file.
A 5 minute cron file
An hour cron file and a day cron file.

Will I be able to run these? All separately?
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
You can NOT run a "1 minute Cron file" with a basic free-hosting accounts

the every five (5) minute job - and the every one (1) hour job - would both try to run at the top (start) of each hour
you can not run two (2) jobs at the same time with a basic free-hosting account

Cron jobs may not request external content - and you can have only one (1) Cron job execution per five (5) minutes with a basic free-hosting account
 
Last edited:

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
Even on a Premium account, where you are allowed 1 minute crons, you would have to set up a schedule where the 1-minute job takes 4 of the 5 minutes, then skips a turn while your 5-minute job runs. Once an hour, it would need to skip an extra turn to allow the hourly to run (or you could skip a turn on the 5-minute job). And once a day you'd need to skip another job to run your daily. That means either a complicated cron schedule or a script that's smart enough to know what it's supposed to do on a particular run.
 

Skizzerz

Contributors
Staff member
Contributors
Messages
2,929
Reaction score
118
Points
63
Even on a Premium account, where you are allowed 1 minute crons, you would have to set up a schedule where the 1-minute job takes 4 of the 5 minutes, then skips a turn while your 5-minute job runs. Once an hour, it would need to skip an extra turn to allow the hourly to run (or you could skip a turn on the 5-minute job). And once a day you'd need to skip another job to run your daily. That means either a complicated cron schedule or a script that's smart enough to know what it's supposed to do on a particular run.

Incorrect. The only one cron running at a time is a restriction only on Free Hosting and Prime (Free Hosting is restricted to one cron running per 5 minutes, Prime is restricted to one cron running per minute). Illuminated and Premium have no restrictions on cron jobs.
 
Status
Not open for further replies.
Top