How do you create a crontab entry via a Bash script? That’s a good question. Here is one solution:

<pre lang="bash">
(crontab -l 2>/dev/null; echo "* 11 * * * /path/to/job -with args") | crontab -

If you want to run it as a specific user, use the following:

<pre lang="bash">
(crontab -l -u user 2>/dev/null; echo "* 11 * * * /path/to/job -with args") | crontab -