Categories: TutorialsUbuntu

How to Schedule Multiple Cron Jobs in One Crontab

Cron jobs are tasks scheduled in Linux systems that run automatically at their scheduled times. They need to be included in crontab document. Often beginner administrators wonder whether they need to create a separate crontab for each cron job, and if they can schedule multiple cron jobs in one crontab. In this article, we will learn how to do this.

How to Schedule Multiple Cron Jobs in One Crontab

If you need to schedule cron job, you need to open crontab document using the following command. It will open the crontab document in your default text editor.

$ crontab -e

If you want to change the default text editor of your system, then run the EXPORT editor command and then run above command. Here is an example to set default editor to vi editor.

Sponsored
class="wp-block-preformatted">$ export EDITOR=vi

Once the crontab -e is run, it will open the document in a text editor. Each line will contain a cronjob of the following format.

Now within a crontab file, you can organize each crojob one below the other such that you have one cron job on each line, or you can organize them one after the other on a single line where the cron jobs are separated by semi colon(;), or it can be a combination of both these approaches.

Here is an example to include a different cron job on separate line.

5 * * * * echo 'hello world'
10 * * * * echo 'good morning'
15 * * * * echo 'how are you'

Here is an example to run multiple cron jobs at the same time.

Sponsored
5 * * * * echo 'hello world'; echo 'good morning'; echo 'how are you'
OR
5 * * * * echo 'hello world' && echo 'good morning' && echo 'how are you'

In the first example, each cron job runs at a different time while in second example, all cron jobs run at the same time.

While we have learnt how to run multiple cron jobs in a single file, you should also remember that it is possible to have different crontabs for each user on your system, each with a separate list of cronjobs.

In this article, we have learnt how to schedule multiple cron jobs in same crob tab.

Also read:

How to POST JSON Data in Python Requests
How to Remove SSL Certificate & SSH Passphrase
How to Capture Linux Signal in Python
How to Send Signal from Python
How to Clear Canvas for Redrawing in JavaScript

The post How to Schedule Multiple Cron Jobs in One Crontab appeared first on Fedingo.

Ubuntu Server Admin

Recent Posts

IBM LinuxONE 5 and Ubuntu Server, a great combination from day one

Today, IBM announced the launch of their latest server: the new IBM LinuxONE Emperor 5.…

8 hours ago

Ubuntu Weekly Newsletter Issue 890

Welcome to the Ubuntu Weekly Newsletter, Issue 890 for the week of April 27 –…

1 day ago

Ubuntu IoT Day in Singapore – Unlock compliant and scalable innovation in edge AI

Singapore | May 27, 2025 | Full-day event How do you build robust, performant edge…

1 day ago

Kolla Ansible OpenStack Installation (Ubuntu 24.04)

Kolla Ansible provides production-ready containers (here, Docker) and deployment tools for operating OpenStack clouds. This…

4 days ago

Canonical announces first Ubuntu Desktop image for Qualcomm Dragonwing™ Platform with Ubuntu 24.04

This public beta enables the full Ubuntu Desktop experience on the Qualcomm Dragonwing™ QCS6490 and…

5 days ago

The long march towards delivering CRA compliance

Time is running out to be in full compliance with the EU Cyber Resilience Act,…

5 days ago