Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appending to crontab with a shell script on Ubuntu

I'm trying to add a line to the crontab on Ubuntu.

Right now, I'm doing crontab -e and editing the crontab there.

However, I can't seem to find the real crontab file, since crontab -e seems to give you a temporary working copy.

/etc/crontab looks like the system crontab.

What is the path of the crontab that crontab -e saves to?

Thanks!

like image 764
Filo Stacks Avatar asked Dec 20 '11 17:12

Filo Stacks


3 Answers

You can also do it without a temporary file:

(crontab -l ; echo "0 4 * * * myscript")| crontab -
like image 125
jeroent Avatar answered Sep 28 '22 04:09

jeroent


Use crontab -l > file to list current user's crontab to the file, and crontab file, to install new crontab.

like image 33
alexander Avatar answered Sep 28 '22 04:09

alexander


If your crontab is empty you should use 2>/dev/null:

(crontab -l 2>/dev/null; echo "0 4 * * * myscript")| crontab -
like image 38
tal4444228 Avatar answered Sep 28 '22 06:09

tal4444228