Reputation: 10172
I have 5-6 jobs to be done by cron, and i have separated php scripts for those jobs.
My question is, which one is better, putting all the jobs in one php script or keeping them in separated php files and entering them to crontab separately ?
thx
Upvotes: 1
Views: 409
Reputation: 23244
I have multiple cron tasks which each run multiple shell scripts which contain multiple php/etc. scripts.
Works very nicely.
Upvotes: 0
Reputation: 258
I'd suggest you to keep all this jobs separately, as this provides you with more flexibility, for example, when setting time.
Upvotes: 1
Reputation: 22638
I'd recommend separate scripts. Primarily it will be much easier to debug/diagnose issues when you get a "failed" email from cron if you know which script was running at the time.
It also allows you to run the other jobs even if one fails more easily.
It also gives you flexibilty to change the timings of different jobs (e.g. suppose you suddenly need to run one every 15mins, but all the others are hourly).
Upvotes: 7
Reputation: 185852
If they all have to run at the same time, then it may be better to write a wrapper script that invokes them all (or enclose them all in one file), and call the one script from cron.
This is especially true if there is an order dependency, such that one script must run before another. Separating these in cron is tricky at best.
If they have to run at different times, then obviously separate cron jobs are warranted.
Upvotes: 1