Edit the crontab without using crontab -e
Target Readers: Linux Newbie
Crontab is like a task schedular in linux and unix operating system.I expect you are already little bit aware about crontab.
In this post I am sharing the tips to new linuxbie ,how to edit crontab without using “crontab -e” command.
As we know to edit the crontab there is a command
crontab -u username -e
This thing you can also do by directly using file editor (like vi,vim or nano etc.).
In Ubuntu and Debian,the crontab file is located at /var/spool/cron/crontabs/ and if any crontab for any user is there ,then file name would be with the name of username.
for eg . username is sharad hence filename will be root. ls -l /var/spool/cron/crontabs/sharad
In CentOS and Redhat, crontab files are located at /var/spool/cron and similarly as I described above, the crontab of user will be with the name of file.
for eg. username is sharad ,and you can see the filename with sharad in ls -l /var/spool/cron/sharad
Now we will edit the crontab directly using the vi editor.
Crontab for username = sharad
In Debian and Ubuntu: below given is an example.
vi /var/spool/cron/crontabs/sharad 10 * * * * touch /tmp/`date +%F-%s` now save and exit from vi editor
In CentOS and Red Hat : Below given is an example
vi /var/spool/cron/sharad 30 * * * * touch /tmp/`date +%F-%s` now save and exit from vi editor
For more understanding , watch the video.