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, :

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

command="$mypath/ > /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 *