Saving Crontab Files

A simple question about crontab, does it matter where I save the crontab files? (creating time-dependent jobs with crontab -e) or can they be read from any directory?

I ask because it seemed like my crontab file was deleted, because when I used crontab -l it did not return anything. However, I think this is because I saved it as a temporary file: Creating more permanent crontab files

+4
source share
3 answers

Typically, crontab used to create the file, and it stores it in the right place for your computer.

 $ crontab < $HOME/etc/crontab 

Then you use crontab -l to list it.

 $ crontab -l # @(#)$Id: crontab,v 4.2 2007/09/17 02:41:00 jleffler Exp $ # Crontab file for Home Directory for Jonathan Leffler (JL) #----------------------------------------------------------------------------- #Min Hour Day Month Weekday Command #----------------------------------------------------------------------------- 0 * * * * /usr/bin/ksh /work4/jleffler/bin/Cron/hourly 1 1 * * * /usr/bin/ksh /work4/jleffler/bin/Cron/daily 23 1 * * 1-5 /usr/bin/ksh /work4/jleffler/bin/Cron/weekday 2 3 * * 0 /usr/bin/ksh /work4/jleffler/bin/Cron/weekly 21 3 1 * * /usr/bin/ksh /work4/jleffler/bin/Cron/monthly $ 

Where I keep my original is immaterial (but it is under source control in $HOME/etc , as it happens). The system has its own copy of the file that it needs.

If you try to place the files manually, you will be bitten. This may work, but then again, perhaps it is not (and this may change in the future). I will not play a risky game using the kosher command to store crontab files for use by crontab .

+6
source

Yes, cron files must be in / var / spool / cron (or some other directory, depending on the system.) See man 8 cron .

+3
source

If you use cron api ( crontab -e or crontab filename for most systems), your cron jobs will be saved in the right place forever, whether you log out or not.

The only way this has not happened is that you are administratively forbidden to use cron (not uncommon).

Remember that the format of the generated file is in the format man 5 crontab . This is not your shell script.

+1
source

All Articles