<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.completenoobs.com/noobs/index.php?action=history&amp;feed=atom&amp;title=Ubuntu_22.04_Cron</id>
	<title>Ubuntu 22.04 Cron - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.completenoobs.com/noobs/index.php?action=history&amp;feed=atom&amp;title=Ubuntu_22.04_Cron"/>
	<link rel="alternate" type="text/html" href="https://www.completenoobs.com/noobs/index.php?title=Ubuntu_22.04_Cron&amp;action=history"/>
	<updated>2026-04-30T06:23:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://www.completenoobs.com/noobs/index.php?title=Ubuntu_22.04_Cron&amp;diff=411&amp;oldid=prev</id>
		<title>Noob: Created page with &quot;==Cron Quick Start==  Cron already comes preinstalled - but if not, install with&lt;br&gt; &lt;code&gt;sudo apt install cron&lt;/code&gt;&lt;br&gt; &lt;br&gt; Cron is a time-based job scheduler in Ubuntu and other Unix-like operating systems. It allows users to schedule commands or scripts to run automatically at specific times or intervals. Cron jobs are very useful for automating repetitive tasks or performing maintenance tasks on a regular basis.&lt;br&gt; &lt;br&gt; To use cron on Ubuntu, you need to underst...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.completenoobs.com/noobs/index.php?title=Ubuntu_22.04_Cron&amp;diff=411&amp;oldid=prev"/>
		<updated>2023-05-11T18:36:08Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Cron Quick Start==  Cron already comes preinstalled - but if not, install with&amp;lt;br&amp;gt; &amp;lt;code&amp;gt;sudo apt install cron&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &amp;lt;br&amp;gt; Cron is a time-based job scheduler in Ubuntu and other Unix-like operating systems. It allows users to schedule commands or scripts to run automatically at specific times or intervals. Cron jobs are very useful for automating repetitive tasks or performing maintenance tasks on a regular basis.&amp;lt;br&amp;gt; &amp;lt;br&amp;gt; To use cron on Ubuntu, you need to underst...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Cron Quick Start==&lt;br /&gt;
&lt;br /&gt;
Cron already comes preinstalled - but if not, install with&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt install cron&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Cron is a time-based job scheduler in Ubuntu and other Unix-like operating systems. It allows users to schedule commands or scripts to run automatically at specific times or intervals. Cron jobs are very useful for automating repetitive tasks or performing maintenance tasks on a regular basis.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To use cron on Ubuntu, you need to understand the syntax of the cron schedule and how to set up a cron job.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The cron schedule consists of five fields: minute, hour, day of the month, month, and day of the week. Each field can be specified with a single value, a range of values, or a list of values separated by commas. Asterisks (*) can be used as wildcards to specify all possible values.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To set up a cron job, you can use the crontab command to edit the cron table. This table contains a list of cron jobs for the current user. Each cron job is specified on a separate line, and consists of the schedule and the command to be executed.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For example, to schedule a script to run every day at midnight, you would add the following line to the crontab:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /path/to/script.sh&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This cron job runs the script.sh file located at /path/to/ every day at midnight (00:00).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; is an asterisk is a wildcard variable that represents all, every day, every hour ... etc&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Syntax: From left to right.&amp;lt;br&amp;gt;&lt;br /&gt;
The first 5 are for time. When to run.&amp;lt;br&amp;gt;&lt;br /&gt;
Minute: &amp;lt;b&amp;gt;0-59&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Hour: &amp;lt;b&amp;gt;0-23&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Day (of the month): &amp;lt;b&amp;gt;1-31&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Month: &amp;lt;b&amp;gt;1-12&amp;lt;/b&amp;gt; or &amp;lt;b&amp;gt;JAN-DEC&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Day (of the week): &amp;lt;b&amp;gt;0-6&amp;lt;/b&amp;gt; or &amp;lt;b&amp;gt;SUN-SAT&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; can be used to create a step value.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Followed by the Command or Script:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;0 5 * * SUN /usr/local/bin/script.sh&amp;lt;/code&amp;gt; will run the script at 5am on sunday.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;*/1 * * * SUN,MON /usr/local/bin/test.sh&amp;lt;/code&amp;gt; will run every minute on sundays and mondays.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;30 3 */3 * * /usr/local/bin/test.sh&amp;lt;/code&amp;gt; will run script at 3:30am every 3 days.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -e&amp;lt;/code&amp;gt; to edit your cron file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
Example to play with:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
Create a quick shell script that will export a time stamp to a log file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;$EDITOR /usr/local/bin/test-cron.sh&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
time_stamp=$(date &amp;#039;+%d_%m_%y %H_%M&amp;#039;)&lt;br /&gt;
echo $time_stamp &amp;gt;&amp;gt; /var/log/noob-test.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;chmod +x /usr/local/bin/test-cron.sh&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Setup Cron to run script every minute:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -e&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;*/1 * * * * /usr/local/bin/test.sh&amp;lt;/pre&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Check your log file:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;cat /var/log/noob-test.sh&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
With cron you can now play around with the dates and time when you want the script to run, and can see time stamp on log file to see if you where correct.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Noob</name></author>
	</entry>
</feed>