How to set a cron job by using the terminal in Ubuntu Server – DGi Host.com

Setting up a cron job using the terminal in Ubuntu Server involves using the crontab command to edit the cron table. Here’s how you can do it:

  1. Open Terminal: Log in to your Ubuntu Server via SSH or open a terminal window if you’re accessing it locally.
  2. Access the Cron Table: Enter the following command to open the cron table for editing:
    crontab -e
  3. Edit the Cron Table: This will open the cron table in a text editor (usually Nano or Vim). The cron table follows a specific format:

    m h dom mon dow command



    m stands for minute (0 – 59)
    h stands for hour (0 – 23)
    dom stands for day of month (1 – 31)
    mon stands for month (1 – 12)
    dow stands for day of week (0 – 7, where 0 and 7 represent Sunday)
    command is the command or script you want to execute

    * * * * /path/to/your/command.sh

    This will run command.sh every minute. Replace /path/to/your/command.sh with the actual path to your script or command.
  4. Save and Exit: Save the changes and exit the text editor. In Nano, you can do this by pressing Ctrl + X, then Y to confirm, and finally Enter. In Vim, you can do this by typing :wq and pressing Enter.
  5. Verify the Cron Job: After saving the cron job, you can verify that it was added correctly by running:
    crontab -l

    This command will list all cron jobs currently set for the user.

That’s it! You’ve successfully set up a cron job using the terminal in Ubuntu Server. Make sure to test your cron job to ensure it runs as expected.


Setting up a cron job using the terminal in Ubuntu Server involves using the crontab command to edit the cron table. Here’s how you can do it: That’s it! You’ve successfully set up a cron job using the terminal in Ubuntu Server. Make sure to test your cron job to ensure it runs as expected.

Leave a Reply

Your email address will not be published. Required fields are marked *