Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export crontab to a file

Tags:

cron

How can I export the contents of the crontab to a file?

I need it because I'm switching usernames and do not want to lose the data in the crontab.

like image 645
Omer Dagan Avatar asked Apr 02 '13 15:04

Omer Dagan


People also ask

How do I save a crontab in a text file?

crontab -e simply fires up the crontab file for that account in your default text editor so you can edit it. With nano, which is the default on ubuntu, you can hit ctrl-x then choose to save. From the comments :wq for Vim and C-x C-s to save and C-x C-c to exit for emacs.


1 Answers

Create the backup (export):

crontab -l > /some/shared/location/crontab.bak 

Import it from the new user:

crontab /some/shared/location/crontab.bak 
like image 66
Omer Dagan Avatar answered Sep 24 '22 02:09

Omer Dagan