Crontab function to ignore specific days

I have a cron tab function and have an idea of how to do this if i was writing std c, but need some advice how to incorporate using code for crontab

What i want is the following

date = getDate();
switch(date){
    case apr 27:
        break;
    case jun 14:
        break;
    default:
        cp /var/spool/asterisk/tmp/playfile.call /tmp && mv /tmp/playfile.call /var/spool/asterisk.outgoing/
        break;
}

There are like 9 times in the year when i do not want the music to play at a specific time as it will interrupt the activities on those days.

cron does not have that ability, but you could use a conditional test on a files existence before it runs your comnand and then use ‘like 9’ “at” commands to touch the conditional file on the appropriate days

Is there a way to integrate a bash file i can initiate that can auto comment out the lines.

Write now i am entering the crontab fille and manually commenting out the lines and then after complete, removing the comments.

But nto sure if i can automate a crontab file edit.

Or i can automate a name change on the file itself. What happens if a file does not exist in the crontab command for cp?

so when it tries and copying the playlist.call, it doesnt exist?

You could do that but it is incredibly ugly, the table will be in /var/spool/cron/crontabs/(user)

if you do that from bash you will need to reload cron.

If the file doesn’t exist the cron job will fail with an email containing the stderr and stdout of the job being sent to the email of the owner of the cron job. Perhaps more elegantly :-

[[ -f (your file) ]] && (do your job)

from a shell

man at

the ‘at’ job can indeed delete the file if it exists when it runs, and you can set the at trigger to be anytime in the future. That way if the file is not there then when the cron job runs, there is no stderr or stdout generated.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.