Adding Cronjob via Script

Here’s another snippet I don’t want to forget,
adding a cronjob via scripting.
Here’s the source for it, : http://stackoverflow.com/questions/878600/how-to-create-cronjob-using-bash

Don’t forget that it only works on BASH! Doesn’t work on sh.

command="$mypath/autograph.sh > /dev/null 2>&1"
job="*/5 * * * * $command"
cat <(grep -i -v "$command" <(crontab -l)) <(echo "$job") | crontab -

Leave a Reply

Your email address will not be published. Required fields are marked *