Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving Crontab files

Tags:

bash

unix

cron

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

I ask because it seemed that my crontab file got deleted because when I used the crontab -l it didn't return anything. However, I think that is because I saved it as a temporary file: Creating more permanent crontab files

like image 945
Phil Braun Avatar asked Dec 22 '22 12:12

Phil Braun


1 Answers

Normally, you use crontab to create the file, and it stores it in the correct place for your machine.

$ 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 where it needs it.

If you try placing the files manually, you will get bitten. It might work, but then again, it might not (and it might change in the future). I wouldn't play the risky game of using other than the kosher command to store crontab files for use by crontab.

like image 61
Jonathan Leffler Avatar answered Dec 27 '22 08:12

Jonathan Leffler