Updating a Cron Job in Ubuntu Linux

Created by Gayathri Daka, Modified on Mon, 22 Apr 2024 at 04:35 PM by Gayathri Daka

In this article, we'll guide you through updating an existing cron job on Ubuntu Linux. But first, let's understand what a cron job is and how it works.
A cron job is a scheduled task that runs in the background at specific intervals set by the user. These tasks are often used for automating repetitive tasks or executing commands at regular intervals.

For our scenario, we want to update a cron job that checks if the "timechamp" application is running every minute. If the application is not running, the cron job will start the application automatically.

To update this cron job, follow these steps

1. Open your terminal in Ubuntu Linux.

2. Type the following command to view your existing cron jobs.

  1. crontab -l


  1. This will display a list of all your current cron jobs.

  2. Identify the cron job that checks and starts the "timechamp" application.

  3. To edit the cron job, type the following command and press Enter:

    crontab -e
  4. This will open the default text editor (usually nano) to edit your cron jobs.

  5. Locate the line corresponding to the cron job you want to update.

  6. Modify the command or schedule as needed. For example, to change the frequency from every minute to every 5 minutes, you would adjust the timing:

    */1 * * * * ~/.local/share/timechamp/timechamp-service ~/.local/share/timechamp/TimeChamp.AppImage time-champ.-tra 2 > ~/.local/share/timechamp/timechamp.log 2>&1

  7. Save the file and exit the text editor. In nano, you can do this by pressing Ctrl + X, then Y to confirm, and Enter to save.

  8. The cron job will now be updated to run according to the new schedule or command.


    Alternatively, you can directly update the cron job using the following command after the initial command:

(crontab -l | grep -v '~/.local/share/timechamp/timechamp-service ~/.local/share/timechamp/TimeChamp.AppImage time-champ.-tra' ; echo "*/1 * * * * ~/.local/share/timechamp/timechamp-service ~/.local/share/timechamp/TimeChamp.AppImage time-champ.-tra 2> ~/.local/share/timechamp/timechamp.log 2>&1") | crontab -



This command will replace the existing cron job with the updated one.



That's it! You've successfully updated a cron job to monitor and start the "timechamp" application on Ubuntu Linux.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article