How to Set Up and Manage Cron Jobs on Linux
To create a cron job that runs under your current user account, execute the following command:
crontab -e
To schedule a cron job for another system user, use the sudo command with the -u flag followed by the target username:
sudo crontab -u <username> -e
This will launch a text editor (Nano is the default on most distributions) where you can add, edit, or remove cron jobs.
Each cron job follows a strict syntax structure:
<minute> <hour> <day> <month> <weekday> <command_or_script_path>
The first five fields define the schedule recurrence, while the final field specifies the full path to the command or script you want to run.
Here are practical examples of scheduled cron jobs:
* * * * * /home/jake/scripts/automate_task.sh: Executes once every minute.0 * * * * /home/jake/scripts/automate_task.sh: Runs once at the start of every hour.0 0 * * * /home/jake/scripts/automate_task.sh: Triggers daily at midnight (12:00 AM).0 9,18 * * * /home/jake/scripts/automate_task.sh: Runs at 9:00 AM and 6:00 PM every day.0 9-18 * * * /home/jake/scripts/automate_task.sh: Executes hourly between 9:00 AM and 6:00 PM (inclusive) daily.*/10 * * * * /home/jake/scripts/automate_task.sh: Runs every 10 minutes.
After configuring your cron jobs, press Ctrl+X to exit the editor, thenn confirm the changes when prompted. The cron daemon will automatically apply the new schedule.
To view all active cron jobs for the current user, run:
crontab -l
For Linux desktop users, a more intuitive graphical option is available. On GNOME-based systems, install and use Gnome Schedule (package name: gnome-schedule), a GUI frontend that simplifies creating and managing cron jobs without using the command line.