
- Kali Linux Tutorial
- Kali Linux - Home
- Installation & Configuration
- Information Gathering Tools
- Vulnerability Analyses Tools
- Kali Linux - Wireless Attacks
- Website Penetration Testing
- Kali Linux - Exploitation Tools
- Kali Linux - Forensics Tools
- Kali Linux - Social Engineering
- Kali Linux - Stressing Tools
- Kali Linux - Sniffing & Spoofing
- Kali Linux - Password Cracking Tools
- Kali Linux - Maintaining Access
- Kali Linux - Reverse Engineering
- Kali Linux - Reporting Tools
- Kali Linux Useful Resources
- Kali Linux - Quick Guide
- Kali Linux - Useful Resources
- Kali Linux - Discussion
How would I get a cron job to run every 30 minutes on Linux?
In order to create a crontab job to run every 30 minutes we first need to explore and understand what a crontab job is.
A crontab is nothing but a list of commands that we can run during a cron job. A cron job is a utility that schedules automatic execution of commands at specific times.
We can start a cron job with the help of bash script by following the commands shown below −
crontab -e
This will open a file which you can edit, insert the cron job shell script in the above file and then close that file.
Just insert the code shown below in the above file
* * * * * sample.sh
The above command contains 5 *, where each * indicates the time and then follows the stars. We have the script which we want to run as a cron job. In the sample.sh we need to write the following command to make the environment variables available to it.
Now we understand how we can create a crontab job, it is time to understand what these * actually mean and how we can replace their values to solve our particular question.
The five * in the above command actually has a separate meaning attached to them.
These mainly mean −
Seconds: 0-59 Minutes: 0-59 Hours: 0-23 Day of Month: 1-31 Months: 0-11 Day of Week: 0-6
Now that we know what the cron job actually means and how it works, it’s time that we understand how we can make a cron job run every 30 minutes.
While there are different variations possible for the same result, the most basic command that will make sure that a job runs when the minute of each hour is 0 or 30 is shown below
Command
0,30 * * * * sample.sh
The above command will make sure that the sample.sh bash script will run when the minute of each hour is 0 or 30 (like it would run at 2:00, 2:30, 3:00).
- Related Articles
- How to Run a Cron Job Every Day on a Linux System
- Run Cron Job Only If It Isn’t Already Running in Linux
- How to run a crontab job every week on Sunday?
- How to Create a Cron Job and Execute at a Given Time in Linux
- How to test a weekly crontab job on Linux?
- Load Environment Variables in a Cron Job
- How to run Linux libraries on Docker on Windows?
- Run a Script on Startup in Linux
- How to Add Cron Jobs to A Specific User in a Linux System
- How do I get a job as a Python developer?
- Run Linux Natively on Windows 10
- Run a Java Application as a Service on Linux
- How to use Boto3 library in Python to run a Glue Job?
- Can I get a job with a Python certificate?
- How to Run a Command Multiple Times in Linux?
