1

I've a lot of users in my server using exactly the same cron schedule and this is causing high server load. Can we prevent this?

For example, if there's x numbers of users that use the following cron schedule: 0 1 * * *, is it possible to prevent future users in using the same cron schedule?

1

3 Answers 3

0

You can assign cron scheduled per user account:

crontab -e -u user
1
  • 1
    This doesn't prevent two users from using the same schedule.
    – slhck
    Mar 22, 2013 at 10:44
0

Why not simply write a script that compares all the user's cron files and moves them on if they conflict? if this is found in several crontabs 0 1 * * * for each conflict that exists change move the minutes along 5 1 * * * and 10 1 * * *. Then simply run this script in the root crontab so that it automatically changes user crontabs often.

If it is crucial that users' cron jobs run at the times they specified you will have to take a look at using PAM limits.

0

If your users simply intend to perform nightly tasks, a solution based on running their ~/nightly.sh might be simpler.

You would then run «/home/*/nightly.sh», one after another. Of course you would have to run each user's script with her own permissions and in a reasonable environment (cron does these things).

But it might be quite simple. For example:

for user in user0 user1 user2 user3 ... 
do 
   script=/home/$user/nightly.sh
   [ -x $script ] || continue 
   sudo -u $user  2>&1 | mail -s "nightly.sh" $user 
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .