Skip to content

How to Edit Cron Jobs in Linux with the crontab Command

Updated 7 min read

Updated: 12 October 2026 · Applies to: cron 3.0pl1 on Debian 13 and Ubuntu 26.04, cronie 1.7.0 on AlmaLinux 10.2 (tested); cronie is also the cron on Rocky Linux and RHEL

To edit cron jobs in Linux, run crontab -e. It opens your crontab in a text editor; change, add or remove lines, then save and close the editor. The crontab command checks the file, prints crontab: installing new crontab and cron uses the new version from the next minute, with no restart. To edit another user's cron jobs, run sudo crontab -u USERNAME -e. To list them first, run crontab -l (a lower-case L, not the number 1).

Quick reference

  • Edit your cron jobs: crontab -e
  • Edit another user's: sudo crontab -u alice -e
  • Edit root's: sudo crontab -e
  • Use a different editor once: EDITOR=nano crontab -e
  • Choose the default editor (Debian, Ubuntu): select-editor
  • Back up before a big change: crontab -l > ~/crontab.bak
  • Check a crontab file without installing it: crontab -n FILE (Debian, Ubuntu) or crontab -T FILE (AlmaLinux, Rocky Linux, RHEL)

1. Open your crontab

Run crontab -e as the user who owns the jobs. On Debian and Ubuntu, the first time you run it without an editor set, you are asked to pick one:

$ crontab -e
no crontab for root - using an empty one
Select an editor.  To change later, run select-editor again.
  1. /bin/nano        <---- easiest
  2. /usr/bin/vim.tiny

Choose 1-2 [1]:

The list depends on the editors installed. Your choice is saved in ~/.selected_editor; run select-editor to change it. On AlmaLinux, Rocky Linux and RHEL there is no menu: crontab opens vi unless you set an editor.

  • nano: press Ctrl+O and Enter to save, then Ctrl+X to close. The keys are listed at the bottom of the screen.
  • vi or vim: press i to start typing, Esc when you are done, then type :wq and press Enter. :q! closes without saving.

2. Use the editor you want

crontab reads the VISUAL and EDITOR variables. When both are set, VISUAL wins; we tested this on Debian 13, Ubuntu 26.04 and AlmaLinux 10.

EDITOR=nano crontab -e                      # this time only
echo 'export EDITOR=nano' >> ~/.bashrc     # from your next login on

If the editor you set is not the one that opens, check whether VISUAL is set: echo $VISUAL. An editor command with options also works; crontab passes the options on.

3. Change a job and save

Each job is one line: minute, hour, day of month, month, day of week, then the command. To move a nightly backup from 03:00 to 02:30, change

0 3 * * * /root/backup.sh

to

30 2 * * * /root/backup.sh

Save and close the editor. The result looks like this:

crontab: installing new crontab

If you close the editor without changing anything, Debian and Ubuntu print No modification made and AlmaLinux prints crontab: no changes made to crontab; nothing is changed. To pause a job without losing it, put # in front of the line. On Debian and Ubuntu a new crontab starts with a block of comment lines that explain the fields; you can leave them.

Common schedules (all passed the syntax check on both cron versions):

* * * * *      /usr/local/bin/task.sh    # every minute
*/5 * * * *    /usr/local/bin/task.sh    # every 5 minutes
30 * * * *     /usr/local/bin/task.sh    # every hour at minute 30
0 3 * * *      /usr/local/bin/task.sh    # every day at 03:00
0 0 * * MON    /usr/local/bin/task.sh    # every Monday at 00:00
0 0 1 */6 *    /usr/local/bin/task.sh    # 1 January and 1 July at 00:00

For the full syntax and how to read existing jobs, see how to list cron jobs and read crontab syntax. To add a first job step by step, see how to add jobs to cron.

4. If crontab rejects your edit

crontab checks the file before it installs it. A wrong value, such as minute 61, gives this on Debian and Ubuntu:

crontab: installing new crontab
"/tmp/crontab.g0zX2k/crontab":25: bad minute
errors in crontab file, can't install.
Do you want to retry the same edit? (y/n)

and this on AlmaLinux:

crontab: installing new crontab
"/tmp/crontab.AU0ebl":3: bad minute
Invalid crontab file, can't install.
Do you want to retry the same edit? (Y/N)

The number after the file name is the line with the problem. Answer y to go back into the editor with your changes, or n to keep the old crontab. Your old jobs keep running either way.

To check a crontab file before you install it, use crontab -n FILE on Debian and Ubuntu (it prints The syntax of the crontab file was successfully checked.) or crontab -T FILE on AlmaLinux, Rocky Linux and RHEL. Do not use -n there: on cronie it sets a cluster host name instead of checking anything.

5. Edit another user's cron jobs

sudo crontab -u alice -e
sudo crontab -u alice -l

sudo crontab -e without -u edits root's crontab, not yours, which is a common reason for "my job disappeared". The files are stored in /var/spool/cron/crontabs/USERNAME on Debian and Ubuntu and in /var/spool/cron/USERNAME on AlmaLinux, Rocky Linux and RHEL. Do not edit them there by hand; crontab -e checks the syntax and sets the right owner and permissions.

6. Edit cron jobs without an interactive editor

In scripts or over a slow connection, pipe the crontab through a command and install the result with crontab -:

crontab -l > ~/crontab.bak                                   # back up
crontab -l | sed 's|/root/backup.sh|/root/backup.sh --full|' | crontab -   # change a line
(crontab -l; echo '*/15 * * * * /usr/local/bin/check.sh') | crontab -        # add a line
crontab ~/crontab.bak                                        # restore the backup

This worked on all three systems, also for a user who had no crontab yet. crontab FILE replaces the whole crontab with the file, so keep the backup until you have checked the result with crontab -l. On AlmaLinux, cronie 1.7 also saves the previous version on every change and tells you so: Backup of root's previous crontab saved to /root/.cache/crontab/crontab.bak.

7. System-wide cron files

/etc/crontab and the files in /etc/cron.d/ are not edited with crontab -e. Open them with sudo nano /etc/cron.d/FILE. Their lines have an extra field after the day of week: the user the command runs as, for example */5 * * * * www-data /usr/bin/php /var/www/app/cron.php. According to the cron manuals, both cron versions notice changes to these files, so no restart is needed here either. On Debian and Ubuntu, a file in /etc/cron.d/ must be owned by root and its name may contain only letters, digits, hyphens and underscores: backup-site runs, backup.cron is ignored.

8. Check that the change worked

  1. Run crontab -l and read the line again.
  2. Wait until the next run time. In our test, a job added while cron was running ran at the start of the next minute.
  3. Check the log: journalctl -u cron on Debian and Ubuntu, journalctl -u crond on AlmaLinux and Rocky Linux. How to list all cron jobs for all users covers this and shows every place a job can hide.

Deleting jobs: careful with -r

To remove one job, delete its line in crontab -e. crontab -r deletes all your cron jobs at once, without asking, and the R key is next to E on the keyboard. crontab -ri asks first:

$ crontab -ri
crontab: really delete root's crontab? (y/n)

On cPanel hosting you edit cron jobs on the Cron Jobs page instead: see cron jobs in cPanel and the video edit or delete a cron job in cPanel. On Plesk, see edit or delete scheduled tasks in Plesk.

Official documentation: crontab manual page (Debian).

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Was this answer helpful?

Still stuck? Open a ticket