Diego
Diego

Reputation: 65

How can I edit crontab in file?

I'm already using crontab, accessing it with "crontab -e" command and it works just fine. It would be great on my case to edit the cron directly in the file, so I'm trying to use the file located in /etc/crontab directory, but for some reason the cron jobs wont execute (just a dummy job).

I tryied to change the permissions or create files in /etc/cron.d but keeps not working.

This is my cron file:

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

 

* * * * * root echo "123" > /home/ubuntu/test.txt

The two first lines was already in the file, so I didn't change that.

Upvotes: 1

Views: 4262

Answers (2)

Varun Manireddy
Varun Manireddy

Reputation: 1

But if you want to edit an existing crontab and delete a particular cron job, you can use the dd option after crontab -e. Suppose, there are 3 old cron jobs set up for different 3 different scripts to run. And, you want to delete one of the cron jobs out of three. You have to use the dd option to delete that specific cron job.

Upvotes: 0

Diego Velez
Diego Velez

Reputation: 1893

Users crontab files are located in this directory /var/spool/cron/crontabs, so you can edit the file you want directly from there

Upvotes: 0

Related Questions