Question

It supposed to be simple, but I must be missing something.

deletelogs file:

0 11 * * 6 ./scripts/deletelogs.sh

backupstuff file:

0 23 * * * ./scripts/backupstuff.sh

crontab -l shows the deletelogs job

If I do crontab backupstuff, then crontab -l shows the backupstuff job.

How can I schedule both, Why can't I list both with crontab -l?

Was it helpful?

Solution

The crontab file can read a set of entries from a file named on its command line:

crontab filename

or from standard input:

echo ... | crontab

Both commands replace the entire crontab.

To combine two input files:

cat file1 file2 | crontab

To add the contents of a file to an existing crontab:

( crontab -l ; cat file ) | crontab

Personally, I keep my entire crontab in a single file, installed with a simple crontab filename; I keep that file under a source control system so I can restore it if I make a mistake. But if you have a need to split it into multiple files, you can do that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top