Is there a way of telling cron that if there is a job with higher priority at the same time it should only execute the higher priority job?
For example:
0 12 * * * ~/ring_a_bell.sh # mplayer bell.wav
would be standard ringing. But one time only for example on my birthday I don't want it to ring_a_bell.sh but to play_a_birthday_mellody.sh:
0 12 21 3 * ~/play_a_birthday_mellody.sh # mplayer birthday.wav
0 12 * * * ~/ring_a_bell.sh # mplayer bell.wav
I read that at-job could do this kind of job but the problem is that both cron
and at
would execute the job at same time. And that wouldn't sound nice. Is there a way of telling cron to check which one has higher priority and only execute one of them?
As far as I know, cron is not smart like that. I can think of one simple way to code your logic in cron, but it's not that nice.
59 11 21 3 * ln -s ~/play_a_birthday_mellody.sh ~/script_which_plays_stuff.sh
5 12 21 3 * ln -s ~/ring_a_bell.sh ~/script_which_plays_stuff.sh
0 12 * * * ~/script_which_plays_stuff.sh
and as a one-time setup, create ~/script_which_plays_stuff.sh
as a symlink to ~/ring_a_bell.sh
Anyway, the conventional way of using cron is for running another script inside which you code your logic.