<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="nl">
	<id>https://thuis.kwantwebdesign.nl/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Erwin</id>
	<title>Installatie Rocky 9 Webserver - Gebruikersbijdragen [nl]</title>
	<link rel="self" type="application/atom+xml" href="https://thuis.kwantwebdesign.nl/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Erwin"/>
	<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Speciaal:Bijdragen/Erwin"/>
	<updated>2026-07-03T10:32:07Z</updated>
	<subtitle>Gebruikersbijdragen</subtitle>
	<generator>MediaWiki 1.39.0</generator>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Linux_commands&amp;diff=121</id>
		<title>Linux commands</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Linux_commands&amp;diff=121"/>
		<updated>2026-03-13T16:55:44Z</updated>

		<summary type="html">&lt;p&gt;Erwin: Nieuwe pagina aangemaakt met 'Om een symbolic link te wijzigen van user:  chown -h remoteopen:remoteopen public_html'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Om een symbolic link te wijzigen van user:&lt;br /&gt;
&lt;br /&gt;
chown -h remoteopen:remoteopen public_html&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Handleidingen_voor_diverse_applicaties_met_Rocky_9&amp;diff=120</id>
		<title>Handleidingen voor diverse applicaties met Rocky 9</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Handleidingen_voor_diverse_applicaties_met_Rocky_9&amp;diff=120"/>
		<updated>2026-03-13T16:55:13Z</updated>

		<summary type="html">&lt;p&gt;Erwin: /* Menu */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Menu =&lt;br /&gt;
&lt;br /&gt;
== Welkom bij mijn verzameling handleidingen: ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mijn kennis van Linux was beperkt, maar door gewoon veel dingen te proberen, leer je snel bij.&lt;br /&gt;
&lt;br /&gt;
Dit gaat het makkelijks als je de beschikking hebt over een (virtual)server of een account bij een grote partij waarbij je op eenvoudige wijze een linus server kunt gebruiken en/of aanmakem.&lt;br /&gt;
&lt;br /&gt;
Ik heb in een thuis omgeving VMware ESXI draaien en kan op die manier snel nieuwe dingen uitproberen.&lt;br /&gt;
&lt;br /&gt;
Als het dan helemaal fout gaat, kun je gewoon opnieuw beginnen.&lt;br /&gt;
&lt;br /&gt;
Ik was in de gelukkige omstandigheden dat ik een vraagbaak inde vorm van een goede vriend achter da hand had.&lt;br /&gt;
&lt;br /&gt;
Hij heeft alle kennis in huis, en als ik er na twee dagen nog niet uit ben, vraag ik hem om mij op weg te helpen.&lt;br /&gt;
&lt;br /&gt;
Ook heeft hij een aantal best practice voorbeelden van installaties, die ik ook hier heb opgenomen.&lt;br /&gt;
&lt;br /&gt;
Ik heb alle topics apart van elkaar gedocumenteerd, en deze zijn eenvoudig via onderstaand menu te bekijken.&lt;br /&gt;
- [[Menu|WireGuard]]&lt;br /&gt;
&lt;br /&gt;
- [[Menu|WireGuard]]&lt;br /&gt;
&lt;br /&gt;
- [[PhpMyAdmin]]&lt;br /&gt;
&lt;br /&gt;
- [[Mariadb|MariaDB]]&lt;br /&gt;
&lt;br /&gt;
- [[Node-red]]&lt;br /&gt;
&lt;br /&gt;
- [[MQTT]]&lt;br /&gt;
&lt;br /&gt;
- [[Wifi via commandline instellen]]&lt;br /&gt;
&lt;br /&gt;
- [[Logging]]&lt;br /&gt;
&lt;br /&gt;
- [[ReadonlyPi]]&lt;br /&gt;
&lt;br /&gt;
- [[Cronjobs]]&lt;br /&gt;
&lt;br /&gt;
- [[Linux commands]]&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=119</id>
		<title>Node-red</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=119"/>
		<updated>2025-06-01T09:38:39Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Hoofdpagina|Menu]]  [[PhpMyAdmin]] [[Mariadb]] [[MQTT]]&lt;br /&gt;
&lt;br /&gt;
Node-Red&lt;br /&gt;
&lt;br /&gt;
Installatie Node-red.&lt;br /&gt;
&lt;br /&gt;
# Installatie&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bash &amp;lt;(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. aanpassen pasword.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once logged in,  a password hash needs to be generated by the Node-RED admin tool. A password hash is an encrypted representation of the chosen password. This prevents the storage of passwords as readable text.&lt;br /&gt;
&lt;br /&gt;
This admin tool is already installed on the Moduline controllers. The commands below can be used directly.&lt;br /&gt;
&lt;br /&gt;
Generate new pasword hash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red admin hash-pw&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, a new password can be chosen. After –''enter''– the hash is generated and is shown. Select the hash and copy it to the clipboard or local file on your computer.&lt;br /&gt;
&lt;br /&gt;
Now we’re going to open the Node-RED settings file where the password hash needs to be stored. The settingsfile is a .js file that can be opened and editted by nano (Linux CLI editor)&lt;br /&gt;
&lt;br /&gt;
Open the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano ~/.node-red/settings.js&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Scroll down (arrow down when using Putty) to ''adminAuth: {''  (see picture)&lt;br /&gt;
&lt;br /&gt;
Replace both hashes for ''password:'' and ''pass:'' with the hash created during former steps. Ensure that the hash is between the quotes!&lt;br /&gt;
&lt;br /&gt;
Note: If another username is required, ''username:'' and ''user:'' can also be changed here.&lt;br /&gt;
&lt;br /&gt;
Once the hashes are replaces with the new one, the file can be saved with:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Na installatie voeg ik de volgende modules toe:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red-contrib-config&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-modbus&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-knx-ultimate&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-buffer-parser&lt;br /&gt;
&lt;br /&gt;
node-red-dashboard&lt;br /&gt;
&lt;br /&gt;
node-red-node-mysql&lt;br /&gt;
&lt;br /&gt;
node-red-node-pushover&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deze kun je toevoegen via de manage-pallets in node-red.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Om een gebruiker toe te voegen:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano ~/.node-red/settings.js&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. 🔐 Genereer een wachtwoord-hash&lt;br /&gt;
&lt;br /&gt;
Node-RED accepteert alleen gehashte wachtwoorden. Maak er één met dit commando (in de terminal):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node -e &amp;quot;console.log(require('bcryptjs').hashSync('jouwWachtwoord', 8));&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Vervang &amp;quot;jouwWachtwoord&amp;quot; door het gewenste wachtwoord. Je krijgt iets zoals:&lt;br /&gt;
&lt;br /&gt;
$2a$08$xJmWvZcZzzqWJZAG2F8JGegjsdFWevgb1raAnzIMLBwKcDj7fzJxe&lt;br /&gt;
&lt;br /&gt;
Voeg gebruiker toe in settings.js&lt;br /&gt;
&lt;br /&gt;
Zoek naar of voeg toe (bij voorkeur net onder adminAuth:):&lt;br /&gt;
&lt;br /&gt;
adminAuth: {&lt;br /&gt;
    type: &amp;quot;credentials&amp;quot;,&lt;br /&gt;
    users: [{&lt;br /&gt;
        username: &amp;quot;admin&amp;quot;,&lt;br /&gt;
        password: &amp;quot;$2a$08$xJmWvZcZzzqWJZAG2F8JGegjsdFWevgb1raAnzIMLBwKcDj7fzJxe&amp;quot;,&lt;br /&gt;
        permissions: &amp;quot;*&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        username: &amp;quot;gebruiker&amp;quot;,&lt;br /&gt;
        password: &amp;quot;$2a$08$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&amp;quot;,&lt;br /&gt;
        permissions: &amp;quot;read&amp;quot;  // alleen lezen&lt;br /&gt;
    }]&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
	•	&amp;quot;permissions&amp;quot;: &amp;quot;*&amp;quot; = volledige toegang (lezen + schrijven)&lt;br /&gt;
	•	&amp;quot;permissions&amp;quot;: &amp;quot;read&amp;quot; = alleen lezen (geen deploy)&lt;br /&gt;
&lt;br /&gt;
Herstart Node-RED&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red-stop&lt;br /&gt;
node-red-start&amp;lt;/code&lt;br /&gt;
&lt;br /&gt;
of &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;systemctl restart nodered&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bcryptjs installeren:&lt;br /&gt;
&lt;br /&gt;
Oplossing: Installeer bcryptjs&lt;br /&gt;
&lt;br /&gt;
1. Open een terminal (macOS/Linux) of command prompt (Windows)&lt;br /&gt;
&lt;br /&gt;
2. Ga naar de map van Node-RED (meestal in je home directory):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd ~/.node-red&lt;br /&gt;
&lt;br /&gt;
npm install bcryptjs&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=118</id>
		<title>Node-red</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=118"/>
		<updated>2025-06-01T09:37:05Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Hoofdpagina|Menu]]  [[PhpMyAdmin]] [[Mariadb]] [[MQTT]]&lt;br /&gt;
&lt;br /&gt;
Node-Red&lt;br /&gt;
&lt;br /&gt;
Installatie Node-red.&lt;br /&gt;
&lt;br /&gt;
# Installatie&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bash &amp;lt;(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. aanpassen pasword.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once logged in,  a password hash needs to be generated by the Node-RED admin tool. A password hash is an encrypted representation of the chosen password. This prevents the storage of passwords as readable text.&lt;br /&gt;
&lt;br /&gt;
This admin tool is already installed on the Moduline controllers. The commands below can be used directly.&lt;br /&gt;
&lt;br /&gt;
Generate new pasword hash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red admin hash-pw&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, a new password can be chosen. After –''enter''– the hash is generated and is shown. Select the hash and copy it to the clipboard or local file on your computer.&lt;br /&gt;
&lt;br /&gt;
Now we’re going to open the Node-RED settings file where the password hash needs to be stored. The settingsfile is a .js file that can be opened and editted by nano (Linux CLI editor)&lt;br /&gt;
&lt;br /&gt;
Open the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano ~/.node-red/settings.js&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Scroll down (arrow down when using Putty) to ''adminAuth: {''  (see picture)&lt;br /&gt;
&lt;br /&gt;
Replace both hashes for ''password:'' and ''pass:'' with the hash created during former steps. Ensure that the hash is between the quotes!&lt;br /&gt;
&lt;br /&gt;
Note: If another username is required, ''username:'' and ''user:'' can also be changed here.&lt;br /&gt;
&lt;br /&gt;
Once the hashes are replaces with the new one, the file can be saved with:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Na installatie voeg ik de volgende modules toe:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red-contrib-config&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-modbus&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-knx-ultimate&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-buffer-parser&lt;br /&gt;
&lt;br /&gt;
node-red-dashboard&lt;br /&gt;
&lt;br /&gt;
node-red-node-mysql&lt;br /&gt;
&lt;br /&gt;
node-red-node-pushover&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deze kun je toevoegen via de manage-pallets in node-red.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Om een gebruiker toe te voegen:&lt;br /&gt;
&lt;br /&gt;
nano ~/.node-red/settings.js&lt;br /&gt;
&lt;br /&gt;
2. 🔐 Genereer een wachtwoord-hash&lt;br /&gt;
&lt;br /&gt;
Node-RED accepteert alleen gehashte wachtwoorden. Maak er één met dit commando (in de terminal):&lt;br /&gt;
&lt;br /&gt;
node -e &amp;quot;console.log(require('bcryptjs').hashSync('jouwWachtwoord', 8));&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Vervang &amp;quot;jouwWachtwoord&amp;quot; door het gewenste wachtwoord. Je krijgt iets zoals:&lt;br /&gt;
&lt;br /&gt;
$2a$08$xJmWvZcZzzqWJZAG2F8JGegjsdFWevgb1raAnzIMLBwKcDj7fzJxe&lt;br /&gt;
&lt;br /&gt;
Voeg gebruiker toe in settings.js&lt;br /&gt;
&lt;br /&gt;
Zoek naar of voeg toe (bij voorkeur net onder adminAuth:):&lt;br /&gt;
&lt;br /&gt;
adminAuth: {&lt;br /&gt;
    type: &amp;quot;credentials&amp;quot;,&lt;br /&gt;
    users: [{&lt;br /&gt;
        username: &amp;quot;admin&amp;quot;,&lt;br /&gt;
        password: &amp;quot;$2a$08$xJmWvZcZzzqWJZAG2F8JGegjsdFWevgb1raAnzIMLBwKcDj7fzJxe&amp;quot;,&lt;br /&gt;
        permissions: &amp;quot;*&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        username: &amp;quot;gebruiker&amp;quot;,&lt;br /&gt;
        password: &amp;quot;$2a$08$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&amp;quot;,&lt;br /&gt;
        permissions: &amp;quot;read&amp;quot;  // alleen lezen&lt;br /&gt;
    }]&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
	•	&amp;quot;permissions&amp;quot;: &amp;quot;*&amp;quot; = volledige toegang (lezen + schrijven)&lt;br /&gt;
	•	&amp;quot;permissions&amp;quot;: &amp;quot;read&amp;quot; = alleen lezen (geen deploy)&lt;br /&gt;
&lt;br /&gt;
Herstart Node-RED&lt;br /&gt;
&lt;br /&gt;
node-red-stop&lt;br /&gt;
node-red-start&lt;br /&gt;
&lt;br /&gt;
of &lt;br /&gt;
&lt;br /&gt;
systemctl restart nodered&lt;br /&gt;
&lt;br /&gt;
bcryptjs installeren:&lt;br /&gt;
&lt;br /&gt;
Oplossing: Installeer bcryptjs&lt;br /&gt;
&lt;br /&gt;
1. Open een terminal (macOS/Linux) of command prompt (Windows)&lt;br /&gt;
&lt;br /&gt;
2. Ga naar de map van Node-RED (meestal in je home directory):&lt;br /&gt;
&lt;br /&gt;
cd ~/.node-red&lt;br /&gt;
&lt;br /&gt;
npm install bcryptjs&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=MQTT&amp;diff=117</id>
		<title>MQTT</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=MQTT&amp;diff=117"/>
		<updated>2025-01-29T18:04:28Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Hoofdpagina|Menu]]  [[PhpMyAdmin]] [[Mariadb]] [[Node-red]]&lt;br /&gt;
&lt;br /&gt;
MQTT installeren&lt;br /&gt;
&lt;br /&gt;
# sudo apt-get install mosquitto&lt;br /&gt;
# sudo apt-get install mosquitto-clients&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Controleren of er berichten binnenkomen:&lt;br /&gt;
&lt;br /&gt;
mosquitto-sub -h 127.0.0.1 -u &amp;lt;user&amp;gt; -P &amp;lt;password&amp;gt; -v -t '#'   (optie:  | grep .........)&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=116</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=116"/>
		<updated>2024-08-25T09:19:15Z</updated>

		<summary type="html">&lt;p&gt;Erwin: /* Command to Execute */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 9 1 1 * /path/to/your_script.sh&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Field&lt;br /&gt;
!Possible Values&lt;br /&gt;
!Syntax&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Minute Within the Hour (MIN)&lt;br /&gt;
|0 – 59&lt;br /&gt;
|7 * * * *&lt;br /&gt;
|The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
|-&lt;br /&gt;
|Hour of the Day (HOUR)&lt;br /&gt;
|0 – 23&lt;br /&gt;
|0 7 * * *&lt;br /&gt;
|The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Month (DOM)&lt;br /&gt;
|1 – 31&lt;br /&gt;
|0 0 7 * *&lt;br /&gt;
|The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
|-&lt;br /&gt;
|Month of the Year (MON)&lt;br /&gt;
|1 - 12 or JAN - DEC&lt;br /&gt;
|0 0 0 7 *&lt;br /&gt;
|The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Week (DOW)&lt;br /&gt;
|0 - 7 or SUN - SAT&lt;br /&gt;
|0 0 * * 7&lt;br /&gt;
|7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Command to Execute ==&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /root/backup.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;chmod +x script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -e&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -u [username] -e&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;15 22 * * * /home/phoenixnap/script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -l&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Examples&lt;br /&gt;
!Run Cron Job&lt;br /&gt;
!Command&lt;br /&gt;
|-&lt;br /&gt;
|Every Minute&lt;br /&gt;
|* * * * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every 15 Minutes&lt;br /&gt;
|*/15 * * * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|On the 30th Minute of Every Hour&lt;br /&gt;
|30 * * * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|At the Beginning of Every Hour&lt;br /&gt;
|0 * * * * /path/to/scrip&lt;br /&gt;
|-&lt;br /&gt;
|Every Day at Midnight&lt;br /&gt;
|0 0 * * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|At 2 AM Every Day&lt;br /&gt;
|0 2 * * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every 1st of the Month&lt;br /&gt;
|0 0 1 * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every 15th of the Month&lt;br /&gt;
|0 0 15 * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|On December 1st - Midnight&lt;br /&gt;
|0 0 1 12 * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Saturdays at Midnight&lt;br /&gt;
|0 0 * * 6 /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every Weekday at 4 AM&lt;br /&gt;
|0 4 * * 1-5 /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|At 4 AM on Tuesdays and Thursdays&lt;br /&gt;
|0 4 * * 2,4 /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every Other Day at 37 Minutes Past the Hour&lt;br /&gt;
|37 1-23/2 * * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every 20 Minutes - Multiple Scripts&lt;br /&gt;
|*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
|-&lt;br /&gt;
|On Saturdays and Sundays at 12 PM&lt;br /&gt;
|0 12 * * 6,0 /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Monday to Friday - Every Hour 9 AM to 5 PM&lt;br /&gt;
|0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)&lt;br /&gt;
|0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Midnight Every Day - Send Output to a Different File&lt;br /&gt;
|0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=115</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=115"/>
		<updated>2024-08-25T09:18:27Z</updated>

		<summary type="html">&lt;p&gt;Erwin: /* CRONJOBS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 9 1 1 * /path/to/your_script.sh&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Field&lt;br /&gt;
!Possible Values&lt;br /&gt;
!Syntax&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Minute Within the Hour (MIN)&lt;br /&gt;
|0 – 59&lt;br /&gt;
|7 * * * *&lt;br /&gt;
|The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
|-&lt;br /&gt;
|Hour of the Day (HOUR)&lt;br /&gt;
|0 – 23&lt;br /&gt;
|0 7 * * *&lt;br /&gt;
|The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Month (DOM)&lt;br /&gt;
|1 – 31&lt;br /&gt;
|0 0 7 * *&lt;br /&gt;
|The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
|-&lt;br /&gt;
|Month of the Year (MON)&lt;br /&gt;
|1 - 12 or JAN - DEC&lt;br /&gt;
|0 0 0 7 *&lt;br /&gt;
|The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Week (DOW)&lt;br /&gt;
|0 - 7 or SUN - SAT&lt;br /&gt;
|0 0 * * 7&lt;br /&gt;
|7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Command to Execute ==&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /root/backup.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;chmod +x script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -e&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -u [username] -e&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;15 22 * * * /home/phoenixnap/script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -l&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Examples&lt;br /&gt;
!Run Cron Job&lt;br /&gt;
!Command&lt;br /&gt;
|-&lt;br /&gt;
|Every Minute&lt;br /&gt;
|* * * * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every 15 Minutes&lt;br /&gt;
|*/15 * * * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|On the 30th Minute of Every Hour&lt;br /&gt;
|30 * * * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|At the Beginning of Every Hour&lt;br /&gt;
|0 * * * * /path/to/scrip&lt;br /&gt;
|-&lt;br /&gt;
|Every Day at Midnight&lt;br /&gt;
|0 0 * * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|At 2 AM Every Day&lt;br /&gt;
|0 2 * * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every 1st of the Month&lt;br /&gt;
|0 0 1 * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every 15th of the Month&lt;br /&gt;
|0 0 15 * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|On December 1st - Midnight&lt;br /&gt;
|0 0 1 12 * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Saturdays at Midnight&lt;br /&gt;
|0 0 * * 6 /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every Weekday at 4 AM&lt;br /&gt;
|0 4 * * 1-5 /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|At 4 AM on Tuesdays and Thursdays&lt;br /&gt;
|0 4 * * 2,4 /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every Other Day at 37 Minutes Past the Hour&lt;br /&gt;
|37 1-23/2 * * * /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every 20 Minutes - Multiple Scripts&lt;br /&gt;
|*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
|-&lt;br /&gt;
|On Saturdays and Sundays at 12 PM&lt;br /&gt;
|0 12 * * 6,0 /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Monday to Friday - Every Hour 9 AM to 5 PM&lt;br /&gt;
|0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
|-&lt;br /&gt;
|Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)&lt;br /&gt;
|0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
|}&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=114</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=114"/>
		<updated>2024-08-25T09:09:27Z</updated>

		<summary type="html">&lt;p&gt;Erwin: /* Command to Execute */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 9 1 1 * /path/to/your_script.sh&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Field&lt;br /&gt;
!Possible Values&lt;br /&gt;
!Syntax&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Minute Within the Hour (MIN)&lt;br /&gt;
|0 – 59&lt;br /&gt;
|7 * * * *&lt;br /&gt;
|The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
|-&lt;br /&gt;
|Hour of the Day (HOUR)&lt;br /&gt;
|0 – 23&lt;br /&gt;
|0 7 * * *&lt;br /&gt;
|The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Month (DOM)&lt;br /&gt;
|1 – 31&lt;br /&gt;
|0 0 7 * *&lt;br /&gt;
|The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
|-&lt;br /&gt;
|Month of the Year (MON)&lt;br /&gt;
|1 - 12 or JAN - DEC&lt;br /&gt;
|0 0 0 7 *&lt;br /&gt;
|The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Week (DOW)&lt;br /&gt;
|0 - 7 or SUN - SAT&lt;br /&gt;
|0 0 * * 7&lt;br /&gt;
|7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Command to Execute ==&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /root/backup.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;chmod +x script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -e&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -u [username] -e&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;15 22 * * * /home/phoenixnap/script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -l&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=113</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=113"/>
		<updated>2024-08-25T07:50:18Z</updated>

		<summary type="html">&lt;p&gt;Erwin: /* Command to Execute */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 9 1 1 * /path/to/your_script.sh&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Field&lt;br /&gt;
!Possible Values&lt;br /&gt;
!Syntax&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Minute Within the Hour (MIN)&lt;br /&gt;
|0 – 59&lt;br /&gt;
|7 * * * *&lt;br /&gt;
|The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
|-&lt;br /&gt;
|Hour of the Day (HOUR)&lt;br /&gt;
|0 – 23&lt;br /&gt;
|0 7 * * *&lt;br /&gt;
|The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Month (DOM)&lt;br /&gt;
|1 – 31&lt;br /&gt;
|0 0 7 * *&lt;br /&gt;
|The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
|-&lt;br /&gt;
|Month of the Year (MON)&lt;br /&gt;
|1 - 12 or JAN - DEC&lt;br /&gt;
|0 0 0 7 *&lt;br /&gt;
|The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Week (DOW)&lt;br /&gt;
|0 - 7 or SUN - SAT&lt;br /&gt;
|0 0 * * 7&lt;br /&gt;
|7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Command to Execute ==&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /root/backup.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;chmod +x script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -e&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -u [username] -e&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;15 22 * * * /home/phoenixnap/script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
crontab -l&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=112</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=112"/>
		<updated>2024-08-25T07:49:52Z</updated>

		<summary type="html">&lt;p&gt;Erwin: /* Command to Execute */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 9 1 1 * /path/to/your_script.sh&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Field&lt;br /&gt;
!Possible Values&lt;br /&gt;
!Syntax&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Minute Within the Hour (MIN)&lt;br /&gt;
|0 – 59&lt;br /&gt;
|7 * * * *&lt;br /&gt;
|The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
|-&lt;br /&gt;
|Hour of the Day (HOUR)&lt;br /&gt;
|0 – 23&lt;br /&gt;
|0 7 * * *&lt;br /&gt;
|The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Month (DOM)&lt;br /&gt;
|1 – 31&lt;br /&gt;
|0 0 7 * *&lt;br /&gt;
|The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
|-&lt;br /&gt;
|Month of the Year (MON)&lt;br /&gt;
|1 - 12 or JAN - DEC&lt;br /&gt;
|0 0 0 7 *&lt;br /&gt;
|The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Week (DOW)&lt;br /&gt;
|0 - 7 or SUN - SAT&lt;br /&gt;
|0 0 * * 7&lt;br /&gt;
|7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Command to Execute ==&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /root/backup.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;chmod +x script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -e&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;crontab -u [username] -e&amp;lt;/c ode&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;15 22 * * * /home/phoenixnap/script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
crontab -l&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=111</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=111"/>
		<updated>2024-08-25T07:48:30Z</updated>

		<summary type="html">&lt;p&gt;Erwin: /* Command to Execute */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 9 1 1 * /path/to/your_script.sh&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Field&lt;br /&gt;
!Possible Values&lt;br /&gt;
!Syntax&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Minute Within the Hour (MIN)&lt;br /&gt;
|0 – 59&lt;br /&gt;
|7 * * * *&lt;br /&gt;
|The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
|-&lt;br /&gt;
|Hour of the Day (HOUR)&lt;br /&gt;
|0 – 23&lt;br /&gt;
|0 7 * * *&lt;br /&gt;
|The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Month (DOM)&lt;br /&gt;
|1 – 31&lt;br /&gt;
|0 0 7 * *&lt;br /&gt;
|The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
|-&lt;br /&gt;
|Month of the Year (MON)&lt;br /&gt;
|1 - 12 or JAN - DEC&lt;br /&gt;
|0 0 0 7 *&lt;br /&gt;
|The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Week (DOW)&lt;br /&gt;
|0 - 7 or SUN - SAT&lt;br /&gt;
|0 0 * * 7&lt;br /&gt;
|7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Command to Execute ==&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /root/backup.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
chmod +x script.sh&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
crontab -e&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
crontab -u [username] -e&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
15 22 * * * /home/phoenixnap/script.sh&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
crontab -l&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=110</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=110"/>
		<updated>2024-08-25T07:47:21Z</updated>

		<summary type="html">&lt;p&gt;Erwin: /* CRONJOBS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 9 1 1 * /path/to/your_script.sh&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Field&lt;br /&gt;
!Possible Values&lt;br /&gt;
!Syntax&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Minute Within the Hour (MIN)&lt;br /&gt;
|0 – 59&lt;br /&gt;
|7 * * * *&lt;br /&gt;
|The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
|-&lt;br /&gt;
|Hour of the Day (HOUR)&lt;br /&gt;
|0 – 23&lt;br /&gt;
|0 7 * * *&lt;br /&gt;
|The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Month (DOM)&lt;br /&gt;
|1 – 31&lt;br /&gt;
|0 0 7 * *&lt;br /&gt;
|The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
|-&lt;br /&gt;
|Month of the Year (MON)&lt;br /&gt;
|1 - 12 or JAN - DEC&lt;br /&gt;
|0 0 0 7 *&lt;br /&gt;
|The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Week (DOW)&lt;br /&gt;
|0 - 7 or SUN - SAT&lt;br /&gt;
|0 0 * * 7&lt;br /&gt;
|7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Command to Execute ==&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /root/backup.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
nano script.sh&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
chmod +x script.sh&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
crontab -e&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
crontab -u [username] -e&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
15 22 * * * /home/phoenixnap/script.sh&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
crontab -l&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=109</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=109"/>
		<updated>2024-08-25T07:46:21Z</updated>

		<summary type="html">&lt;p&gt;Erwin: /* CRONJOBS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:0 9 1 1 * /path/to/your_script.sh Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Field&lt;br /&gt;
!Possible Values&lt;br /&gt;
!Syntax&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Minute Within the Hour (MIN)&lt;br /&gt;
|0 – 59&lt;br /&gt;
|7 * * * *&lt;br /&gt;
|The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
|-&lt;br /&gt;
|Hour of the Day (HOUR)&lt;br /&gt;
|0 – 23&lt;br /&gt;
|0 7 * * *&lt;br /&gt;
|The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Month (DOM)&lt;br /&gt;
|1 – 31&lt;br /&gt;
|0 0 7 * *&lt;br /&gt;
|The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
|-&lt;br /&gt;
|Month of the Year (MON)&lt;br /&gt;
|1 - 12 or JAN - DEC&lt;br /&gt;
|0 0 0 7 *&lt;br /&gt;
|The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Week (DOW)&lt;br /&gt;
|0 - 7 or SUN - SAT&lt;br /&gt;
|0 0 * * 7&lt;br /&gt;
|7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Command to Execute ==&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /root/backup.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
nano script.sh&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
chmod +x script.sh&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
crontab -e&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
crontab -u [username] -e&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
15 22 * * * /home/phoenixnap/script.sh&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
crontab -l&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=108</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=108"/>
		<updated>2024-08-25T07:43:57Z</updated>

		<summary type="html">&lt;p&gt;Erwin: /* CRONJOBS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&amp;lt;blockquote&amp;gt;0 9 1 1 * /path/to/your_script.sh&amp;lt;/blockquote&amp;gt;Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Field&lt;br /&gt;
!Possible Values&lt;br /&gt;
!Syntax&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Minute Within the Hour (MIN)&lt;br /&gt;
|0 – 59&lt;br /&gt;
|7 * * * *&lt;br /&gt;
|The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
|-&lt;br /&gt;
|Hour of the Day (HOUR)&lt;br /&gt;
|0 – 23&lt;br /&gt;
|0 7 * * *&lt;br /&gt;
|The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Month (DOM)&lt;br /&gt;
|1 – 31&lt;br /&gt;
|0 0 7 * *&lt;br /&gt;
|The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
|-&lt;br /&gt;
|Month of the Year (MON)&lt;br /&gt;
|1 - 12 or JAN - DEC&lt;br /&gt;
|0 0 0 7 *&lt;br /&gt;
|The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Week (DOW)&lt;br /&gt;
|0 - 7 or SUN - SAT&lt;br /&gt;
|0 0 * * 7&lt;br /&gt;
|7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Command to Execute ==&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /root/backup.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
nano script.sh&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
chmod +x script.sh&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
crontab -e&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
crontab -u [username] -e&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
15 22 * * * /home/phoenixnap/script.sh&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
crontab -l&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=107</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=107"/>
		<updated>2024-08-25T07:43:16Z</updated>

		<summary type="html">&lt;p&gt;Erwin: /* CRONJOBS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
0 9 1 1 * /path/to/your_script.sh&lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Field&lt;br /&gt;
!Possible Values&lt;br /&gt;
!Syntax&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Minute Within the Hour (MIN)&lt;br /&gt;
|0 – 59&lt;br /&gt;
|7 * * * *&lt;br /&gt;
|The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
|-&lt;br /&gt;
|Hour of the Day (HOUR)&lt;br /&gt;
|0 – 23&lt;br /&gt;
|0 7 * * *&lt;br /&gt;
|The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Month (DOM)&lt;br /&gt;
|1 – 31&lt;br /&gt;
|0 0 7 * *&lt;br /&gt;
|The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
|-&lt;br /&gt;
|Month of the Year (MON)&lt;br /&gt;
|1 - 12 or JAN - DEC&lt;br /&gt;
|0 0 0 7 *&lt;br /&gt;
|The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Week (DOW)&lt;br /&gt;
|0 - 7 or SUN - SAT&lt;br /&gt;
|0 0 * * 7&lt;br /&gt;
|7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Command to Execute ==&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /root/backup.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
nano script.sh&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
chmod +x script.sh&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
crontab -e&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
crontab -u [username] -e&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
15 22 * * * /home/phoenixnap/script.sh&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
crontab -l&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=106</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=106"/>
		<updated>2024-08-25T07:41:17Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 9 1 1 * /path/to/your_script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Field&lt;br /&gt;
!Possible Values&lt;br /&gt;
!Syntax&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Minute Within the Hour (MIN)&lt;br /&gt;
|0 – 59&lt;br /&gt;
|7 * * * *&lt;br /&gt;
|The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
|-&lt;br /&gt;
|Hour of the Day (HOUR)&lt;br /&gt;
|0 – 23&lt;br /&gt;
|0 7 * * *&lt;br /&gt;
|The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Month (DOM)&lt;br /&gt;
|1 – 31&lt;br /&gt;
|0 0 7 * *&lt;br /&gt;
|The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
|-&lt;br /&gt;
|Month of the Year (MON)&lt;br /&gt;
|1 - 12 or JAN - DEC&lt;br /&gt;
|0 0 0 7 *&lt;br /&gt;
|The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
|-&lt;br /&gt;
|Day of the Week (DOW)&lt;br /&gt;
|0 - 7 or SUN - SAT&lt;br /&gt;
|0 0 * * 7&lt;br /&gt;
|7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Command to Execute ==&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /root/backup.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
nano script.sh&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
chmod +x script.sh&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
crontab -e&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
crontab -u [username] -e&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
15 22 * * * /home/phoenixnap/script.sh&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
crontab -l&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=105</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=105"/>
		<updated>2024-08-25T07:31:06Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 9 1 1 * /path/to/your_script.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
Field	Possible Values	Syntax	Description&lt;br /&gt;
Minute Within the Hour (MIN)	0 – 59	7 * * * * 	The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
Hour of the Day&lt;br /&gt;
(HOUR)	0 – 23	0 7 * * *	The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
Day of the Month (DOM)	1 – 31	0 0 7 * * 	The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
Month of the Year (MON)	1 - 12 or JAN - DEC	0 0 0 7 *	The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
Day of the Week&lt;br /&gt;
(DOW)	0 - 7 or SUN - SAT	0 0 * * 7 	7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
Command to Execute&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;0 0 * * * /root/backup.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
nano script.sh&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
chmod +x script.sh&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
crontab -e&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
crontab -u [username] -e&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
15 22 * * * /home/phoenixnap/script.sh&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
crontab -l&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=104</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=104"/>
		<updated>2024-08-25T06:30:14Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
0 9 1 1 * /path/to/your_script.sh&lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
Field	Possible Values	Syntax	Description&lt;br /&gt;
Minute Within the Hour (MIN)	0 – 59	7 * * * * 	The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
Hour of the Day&lt;br /&gt;
(HOUR)	0 – 23	0 7 * * *	The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
Day of the Month (DOM)	1 – 31	0 0 7 * * 	The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
Month of the Year (MON)	1 - 12 or JAN - DEC	0 0 0 7 *	The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
Day of the Week&lt;br /&gt;
(DOW)	0 - 7 or SUN - SAT	0 0 * * 7 	7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
Command to Execute&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /root/backup.sh&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
nano script.sh&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
chmod +x script.sh&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
crontab -e&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
crontab -u [username] -e&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
15 22 * * * /home/phoenixnap/script.sh&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
crontab -l&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=103</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=103"/>
		<updated>2024-08-25T06:28:58Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==CRONJOBS==&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
0 9 1 1 * /path/to/your_script.sh&lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
Field	Possible Values	Syntax	Description&lt;br /&gt;
Minute Within the Hour (MIN)	0 – 59	7 * * * * 	The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
Hour of the Day&lt;br /&gt;
(HOUR)	0 – 23	0 7 * * *	The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
Day of the Month (DOM)	1 – 31	0 0 7 * * 	The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
Month of the Year (MON)	1 - 12 or JAN - DEC	0 0 0 7 *	The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
Day of the Week&lt;br /&gt;
(DOW)	0 - 7 or SUN - SAT	0 0 * * 7 	7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
Command to Execute&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /root/backup.sh&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
nano script.sh&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
chmod +x script.sh&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
crontab -e&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
crontab -u [username] -e&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
15 22 * * * /home/phoenixnap/script.sh&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
crontab -l&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
Conclusion&lt;br /&gt;
&lt;br /&gt;
Thanks to the examples presented in this tutorial, you can now create and schedule cron jobs in Linux and automate routine sysadmin tasks.&lt;br /&gt;
&lt;br /&gt;
Next, learn how to schedule a cron job to run at system reboot.&lt;br /&gt;
Was this article helpful?&lt;br /&gt;
YesNo&lt;br /&gt;
Share on X (Twitter)&lt;br /&gt;
Share on Facebook&lt;br /&gt;
Share on LinkedIn&lt;br /&gt;
Share on Email&lt;br /&gt;
Vladimir Kaplarevic&lt;br /&gt;
Vladimir is a resident Tech Writer at phoenixNAP. He has more than 7 years of experience in implementing e-commerce and online payment solutions with various global IT services providers. His articles aim to instill a passion for innovative technologies in others by providing practical advice and using an engaging writing style.&lt;br /&gt;
Next you should read&lt;br /&gt;
SysAdmin Web Servers&lt;br /&gt;
Linux Commands Cheat Sheet&lt;br /&gt;
November 2, 2023&lt;br /&gt;
A list of all the important Linux commands in one place. Find the command you need, whenever you need it or download our Linux Commands Cheat Sheet and save it for future reference.&lt;br /&gt;
Read more&lt;br /&gt;
SysAdmin&lt;br /&gt;
How to Run Linux Commands in Background&lt;br /&gt;
July 5, 2023&lt;br /&gt;
Executing Linux commands in the background allows users to avoid waiting for one process to complete before entering another command. This guide explains different ways to run Linux commands in the background.&lt;br /&gt;
Read more&lt;br /&gt;
SysAdmin&lt;br /&gt;
How to Create Symbolic Link (Symlink) in Linux&lt;br /&gt;
December 4, 2023&lt;br /&gt;
In Linux, symbolic links are used to easily manage and access files. This tutorial covers how to create, manage, and delete links in the Linux terminal using the ln command.&lt;br /&gt;
Read more&lt;br /&gt;
Security SysAdmin&lt;br /&gt;
User Management in Linux&lt;br /&gt;
November 23, 2023&lt;br /&gt;
This article explains how user management in Linux works and outlines the most commonly used commands for managing users.&lt;br /&gt;
Read more&lt;br /&gt;
RECENT POSTS&lt;br /&gt;
&lt;br /&gt;
    How to Use APT Package Manager&lt;br /&gt;
    How to Install Elasticsearch on Ubuntu&lt;br /&gt;
    How to Mount Remote File Systems via SSHFS on macOS&lt;br /&gt;
    Ubuntu Package Managers Overview&lt;br /&gt;
    Nginx Reverse Proxy for Kibana: How to Configure&lt;br /&gt;
&lt;br /&gt;
CATEGORIES&lt;br /&gt;
&lt;br /&gt;
    SysAdmin&lt;br /&gt;
    Virtualization&lt;br /&gt;
    DevOps and Development&lt;br /&gt;
    Security&lt;br /&gt;
    Backup and Recovery&lt;br /&gt;
    Bare Metal Servers&lt;br /&gt;
    Web Servers&lt;br /&gt;
    Networking&lt;br /&gt;
    Databases&lt;br /&gt;
&lt;br /&gt;
COLOCATION&lt;br /&gt;
&lt;br /&gt;
    Phoenix&lt;br /&gt;
    Ashburn&lt;br /&gt;
    Amsterdam&lt;br /&gt;
    Atlanta&lt;br /&gt;
    Belgrade&lt;br /&gt;
    Singapore&lt;br /&gt;
&lt;br /&gt;
PROMOTIONS&lt;br /&gt;
SERVERS&lt;br /&gt;
&lt;br /&gt;
    Dedicated Servers&lt;br /&gt;
    Database Servers&lt;br /&gt;
    Virtualization Servers&lt;br /&gt;
    High Performance Computing (HPC) Servers&lt;br /&gt;
    Dedicated Streaming Servers&lt;br /&gt;
    Dedicated Game Servers&lt;br /&gt;
    Dedicated Storage Servers&lt;br /&gt;
    SQL Server Hosting&lt;br /&gt;
    Dedicated Servers in Amsterdam&lt;br /&gt;
    Cloud Servers in Europe&lt;br /&gt;
    Big Memory Infrastructure&lt;br /&gt;
&lt;br /&gt;
BUY NOW&lt;br /&gt;
CLOUD SERVICES&lt;br /&gt;
&lt;br /&gt;
    Data Security Cloud&lt;br /&gt;
    VPDC&lt;br /&gt;
    Managed Private Cloud&lt;br /&gt;
    Object Storage&lt;br /&gt;
&lt;br /&gt;
SERVERS&lt;br /&gt;
&lt;br /&gt;
    Disaster Recovery&lt;br /&gt;
    Web Hosting Reseller&lt;br /&gt;
    SaaS Hosting&lt;br /&gt;
&lt;br /&gt;
INDUSTRIES&lt;br /&gt;
&lt;br /&gt;
    Web Hosting Providers&lt;br /&gt;
    Legal&lt;br /&gt;
    MSPs &amp;amp; VARs&lt;br /&gt;
    Media Hosting&lt;br /&gt;
    Online Gaming&lt;br /&gt;
    SaaS Hosting Solutions&lt;br /&gt;
    Ecommerce Hosting Solutions&lt;br /&gt;
&lt;br /&gt;
COMPLIANCE&lt;br /&gt;
&lt;br /&gt;
    HIPAA Ready Hosting&lt;br /&gt;
    PCI Compliant Hosting&lt;br /&gt;
&lt;br /&gt;
NEEDS&lt;br /&gt;
&lt;br /&gt;
    Disaster Recovery Solutions&lt;br /&gt;
    High Availability Solutions&lt;br /&gt;
    Cloud Evaluation&lt;br /&gt;
&lt;br /&gt;
COMPANY&lt;br /&gt;
&lt;br /&gt;
    About Us&lt;br /&gt;
    GitHub&lt;br /&gt;
    Blog&lt;br /&gt;
    RFP Template&lt;br /&gt;
    Careers&lt;br /&gt;
&lt;br /&gt;
CONNECT&lt;br /&gt;
&lt;br /&gt;
    Events&lt;br /&gt;
    Press&lt;br /&gt;
    Contact Us&lt;br /&gt;
&lt;br /&gt;
    PhoenixNAP Home&lt;br /&gt;
    Blog&lt;br /&gt;
    Resources&lt;br /&gt;
    Glossary&lt;br /&gt;
    GitHub&lt;br /&gt;
    RFP Template&lt;br /&gt;
&lt;br /&gt;
     Live Chat  Get a Quote  Support | 1-855-330-1509  Sales | 1-877-588-5918 &lt;br /&gt;
&lt;br /&gt;
    Contact Us&lt;br /&gt;
    Legal&lt;br /&gt;
    Privacy Policy&lt;br /&gt;
    Terms of Use&lt;br /&gt;
    DMCA&lt;br /&gt;
    GDPR&lt;br /&gt;
    Sitemap&lt;br /&gt;
&lt;br /&gt;
Privacy Center Do not sell or share my personal information&lt;br /&gt;
©2024 Copyright phoenixNAP | Global IT Services. All Rights Reserved.&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=102</id>
		<title>Cronjobs</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Cronjobs&amp;diff=102"/>
		<updated>2024-08-25T06:28:02Z</updated>

		<summary type="html">&lt;p&gt;Erwin: Nieuwe pagina aangemaakt met 'CRONJOBS  How to Create and Set Up a Cron Job in Linux January 31, 2024 croncrontablinux  Home » SysAdmin » How to Create and Set Up a Cron Job in Linux  Introduction  The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.  Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearin...'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CRONJOBS&lt;br /&gt;
&lt;br /&gt;
How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
January 31, 2024&lt;br /&gt;
croncrontablinux&lt;br /&gt;
&lt;br /&gt;
Home » SysAdmin » How to Create and Set Up a Cron Job in Linux&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
&lt;br /&gt;
The Cron daemon is a built-in Linux utility that reads the crontab (cron table) file and executes commands and scripts at predefined times and intervals.&lt;br /&gt;
&lt;br /&gt;
Users set up cron jobs in the crontab to streamline routine maintenance activities, such as updating software, creating backups, or clearing caches.&lt;br /&gt;
&lt;br /&gt;
Learn how to set up a cron job in Linux and lighten your workload by automating repetitive tasks.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
&lt;br /&gt;
    A system running Linux.&lt;br /&gt;
    Access to a command line or terminal window.&lt;br /&gt;
&lt;br /&gt;
Basic Crontab Syntax&lt;br /&gt;
&lt;br /&gt;
The syntax of a cron job line in a crontab file must use the following format:&lt;br /&gt;
&lt;br /&gt;
MIN HOUR DOM MON DOW CMD&lt;br /&gt;
&lt;br /&gt;
The first five fields, each separated by a single space, represent time intervals: MIN for minutes, HOUR for hours, DOM for day of the month, MON for month, and DOW for day of the week. They tell Cron when to initiate the cron job.&lt;br /&gt;
&lt;br /&gt;
These fields are followed by the command (CMD), which is usually a path to a script or a system command. For example, the following line prompts Cron to execute a script on January 1st at 9 AM:&lt;br /&gt;
&lt;br /&gt;
0 9 1 1 * /path/to/your_script.sh&lt;br /&gt;
&lt;br /&gt;
Each field has its own set of permissible values, which can be accompanied or swapped for a special character. The asterisk (*) operator in this example instructs Cron to execute the job regardless of which day of the week falls on January 1st.&lt;br /&gt;
Cron Job Time Format&lt;br /&gt;
&lt;br /&gt;
This table lists possible values for the time fields in a cron expression:&lt;br /&gt;
Field	Possible Values	Syntax	Description&lt;br /&gt;
Minute Within the Hour (MIN)	0 – 59	7 * * * * 	The cron job is initiated every time the system clock shows 7 in the minute's position.&lt;br /&gt;
Hour of the Day&lt;br /&gt;
(HOUR)	0 – 23	0 7 * * *	The cron job runs any time the system clock shows 7 AM (7 PM would be coded as 19).&lt;br /&gt;
Day of the Month (DOM)	1 – 31	0 0 7 * * 	The day of the month is 7, which means that the job runs every 7th day of the month.&lt;br /&gt;
Month of the Year (MON)	1 - 12 or JAN - DEC	0 0 0 7 *	The numerical month is 7, which determines that the job runs only in July. The Month field value can be a number or the month abbreviation.&lt;br /&gt;
Day of the Week&lt;br /&gt;
(DOW)	0 - 7 or SUN - SAT	0 0 * * 7 	7 in the current position means that the job would only run on Sundays. The Day of the Week field can be a number or the day abbreviation.&lt;br /&gt;
Command to Execute&lt;br /&gt;
&lt;br /&gt;
After defining the schedule, enter the absolute path to the script or executable command you want Cron to complete. For example, the following command tells Cron to execute the backup.sh script, located in the root directory, every day at midnight:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /root/backup.sh&lt;br /&gt;
&lt;br /&gt;
Users must ensure their scripts have appropriate execute permissions and that the Cron service can access and run scripts in the specified directories.&lt;br /&gt;
Using Operators&lt;br /&gt;
&lt;br /&gt;
Operators are special characters used instead of or in conjunction with allowed field values. They simplify and shorten cron expressions and are integral to almost all cron jobs. The most frequently used operators include:&lt;br /&gt;
&lt;br /&gt;
    An asterisk (*) substitutes all possible values for a time field. For example, when used in the day field, it indicates that the task should be executed every day.&lt;br /&gt;
    A comma (,) is used to separate individual values within a field. For example, 20,40 in the minute field runs the task at 20 and 40 minutes past the hour.&lt;br /&gt;
    A dash (-) defines a range of values in a single field. Entering 15-18 in the minute field instructs Cron to run a task every minute between and including the 15th and 18th minute.&lt;br /&gt;
    A forward slash (/) divides a field value into increments. For example, */30 in the minute field means that the task is run every 30 minutes.&lt;br /&gt;
&lt;br /&gt;
Note: If you also manage Windows systems, learn how to set up a Cron Job on Windows.&lt;br /&gt;
Setting Up a Cron Job&lt;br /&gt;
&lt;br /&gt;
To configure a cron job, open the crontab file using a preferred text editor and input the syntax for the command or script you want to run.&lt;br /&gt;
&lt;br /&gt;
Follow the steps below to configure a cron job.&lt;br /&gt;
1. Write a Script (Optional)&lt;br /&gt;
&lt;br /&gt;
This section explains how to create an example script. If you already have a script ready, skip to the next section.&lt;br /&gt;
&lt;br /&gt;
To write a simple UNIX shell script:&lt;br /&gt;
&lt;br /&gt;
1. Use a text editor, like nano, and create a new .sh file. The file in this example is named script.sh:&lt;br /&gt;
&lt;br /&gt;
nano script.sh&lt;br /&gt;
&lt;br /&gt;
2. Utilize a preferred Linux shell to write a script for the cron job to run. For example, to create a Bash script, start with the shebang expression. Enter the path to the Bash binary and list the commands that you want to execute:&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
echo &amp;quot;Current Date and Time: $(date)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example of a script used by a cron job.&lt;br /&gt;
&lt;br /&gt;
The echo &amp;quot;Current Date and Time: $(date)&amp;quot; command displays the current date and time when the cron job is executed.&lt;br /&gt;
&lt;br /&gt;
3. Save and exit the file.&lt;br /&gt;
&lt;br /&gt;
4. Enter the chmod command to ensure that script.sh has appropriate execute permissions:&lt;br /&gt;
&lt;br /&gt;
chmod +x script.sh&lt;br /&gt;
&lt;br /&gt;
2. Create or Edit Crontab File&lt;br /&gt;
&lt;br /&gt;
Open the crontab configuration file for the current user by entering the following command:&lt;br /&gt;
&lt;br /&gt;
crontab -e&lt;br /&gt;
&lt;br /&gt;
If this is your first time accessing the crontab, the system creates a new file. In Ubuntu 22.04, users are prompted to select a preferred text editor. Enter the corresponding number, for example, 1 for nano, to open the crontab file.&lt;br /&gt;
Accessing the crontab file in Linux.&lt;br /&gt;
&lt;br /&gt;
To schedule a job for a different user, add the -u option and the username:&lt;br /&gt;
&lt;br /&gt;
crontab -u [username] -e&lt;br /&gt;
&lt;br /&gt;
Note: Use the sudo command when accessing crontab for system-level tasks or tasks requiring administrative privileges. For regular user-level tasks, sudo is not necessary.&lt;br /&gt;
3. Create the Cron Job&lt;br /&gt;
&lt;br /&gt;
Add a line containing a cron expression and the path to a script. This example uses the path to script.sh created earlier:&lt;br /&gt;
&lt;br /&gt;
15 22 * * * /home/phoenixnap/script.sh&lt;br /&gt;
&lt;br /&gt;
The cron job entry will run script.sh every day at 10:15 PM.&lt;br /&gt;
An example of a cron job in the crontab file.&lt;br /&gt;
&lt;br /&gt;
Remember to specify the complete, absolute path to where the script is located. You can add an infinite number of scheduled tasks. Each task must be in a separate line.&lt;br /&gt;
4. Output (Optional)&lt;br /&gt;
&lt;br /&gt;
Cron sends an email to the owner of the crontab file with the cron job output. The format of cron emails can vary based on the system email configuration and the script's output.&lt;br /&gt;
Cron email example.&lt;br /&gt;
&lt;br /&gt;
This feature is convenient for tracking tasks, but emails for frequent or minor tasks can be spammy. Users can disable email output for specific cron jobs.&lt;br /&gt;
&lt;br /&gt;
To turn off email output, add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 at the end of the cron job line:&lt;br /&gt;
&lt;br /&gt;
0 0 * * * /path/to/script.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
The output is redirected to the /dev/null file that discards all data written to it. Use this method to redirect output to any file in the filesystem.&lt;br /&gt;
&lt;br /&gt;
Alternatively, to direct Cron emails to a specific address, add the MAILTO variable followed by a valid email address above a cron job.&lt;br /&gt;
MAILTO option in the crontab file.&lt;br /&gt;
&lt;br /&gt;
If MAILTO is left empty (MAILTO=''), Cron will not send emails for jobs listed below the variable.&lt;br /&gt;
5. Save&lt;br /&gt;
&lt;br /&gt;
Once you have finished adding tasks, save and exit the crontab file. There is no need to restart Cron to apply the changes.&lt;br /&gt;
&lt;br /&gt;
The daemon will automatically read and execute the provided instructions.&lt;br /&gt;
6. Check Active Cron Jobs&lt;br /&gt;
&lt;br /&gt;
Enter the following command to list all cron jobs on your system without opening the crontab configuration file:&lt;br /&gt;
&lt;br /&gt;
crontab -l&lt;br /&gt;
&lt;br /&gt;
A list of cron jobs in terminal window.&lt;br /&gt;
Cron Job on Linux: Examples&lt;br /&gt;
&lt;br /&gt;
The following table provides basic cron job command examples. Replace /path/to/script with the actual, absolute path of your script on your system.&lt;br /&gt;
Run Cron Job	Command&lt;br /&gt;
Every Minute	* * * * * /path/to/script&lt;br /&gt;
Every 15 Minutes	*/15 * * * * /path/to/script&lt;br /&gt;
On the 30th Minute of Every Hour	30 * * * * /path/to/script&lt;br /&gt;
At the Beginning of Every Hour	0 * * * * /path/to/script&lt;br /&gt;
Every Day at Midnight	0 0 * * * /path/to/script&lt;br /&gt;
At 2 AM Every Day	0 2 * * * /path/to/script&lt;br /&gt;
Every 1st of the Month	0 0 1 * * /path/to/script&lt;br /&gt;
Every 15th of the Month	0 0 15 * * /path/to/script&lt;br /&gt;
On December 1st - Midnight	0 0 1 12 * /path/to/script&lt;br /&gt;
Saturdays at Midnight	0 0 * * 6 /path/to/script&lt;br /&gt;
Every Weekday at 4 AM	0 4 * * 1-5 /path/to/script&lt;br /&gt;
At 4 AM on Tuesdays and Thursdays	0 4 * * 2,4 /path/to/script&lt;br /&gt;
Every Other Day at 37 Minutes Past the Hour	37 1-23/2 * * * /path/to/script&lt;br /&gt;
Every 20 Minutes - Multiple Scripts	*/20 * * * * /path/to/script1; /path/to/script2&lt;br /&gt;
On Saturdays and Sundays at 12 PM	0 12 * * 6,0 /path/to/script&lt;br /&gt;
Monday to Friday - Every Hour 9 AM to 5 PM	0 9-17 * * 1-5 /path/to/script&lt;br /&gt;
Every Hour from 5 PM on Wednesday to 5 AM on Thursday (Job Spans Two Days)	0 17-23 * * 3 /path/to/script&lt;br /&gt;
0 0-5 * * 4 /path/to/script&lt;br /&gt;
Midnight Every Day - Send Output to a Different File	0 0 * * * /path/to/script &amp;gt; /path/to/output.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
Conclusion&lt;br /&gt;
&lt;br /&gt;
Thanks to the examples presented in this tutorial, you can now create and schedule cron jobs in Linux and automate routine sysadmin tasks.&lt;br /&gt;
&lt;br /&gt;
Next, learn how to schedule a cron job to run at system reboot.&lt;br /&gt;
Was this article helpful?&lt;br /&gt;
YesNo&lt;br /&gt;
Share on X (Twitter)&lt;br /&gt;
Share on Facebook&lt;br /&gt;
Share on LinkedIn&lt;br /&gt;
Share on Email&lt;br /&gt;
Vladimir Kaplarevic&lt;br /&gt;
Vladimir is a resident Tech Writer at phoenixNAP. He has more than 7 years of experience in implementing e-commerce and online payment solutions with various global IT services providers. His articles aim to instill a passion for innovative technologies in others by providing practical advice and using an engaging writing style.&lt;br /&gt;
Next you should read&lt;br /&gt;
SysAdmin Web Servers&lt;br /&gt;
Linux Commands Cheat Sheet&lt;br /&gt;
November 2, 2023&lt;br /&gt;
A list of all the important Linux commands in one place. Find the command you need, whenever you need it or download our Linux Commands Cheat Sheet and save it for future reference.&lt;br /&gt;
Read more&lt;br /&gt;
SysAdmin&lt;br /&gt;
How to Run Linux Commands in Background&lt;br /&gt;
July 5, 2023&lt;br /&gt;
Executing Linux commands in the background allows users to avoid waiting for one process to complete before entering another command. This guide explains different ways to run Linux commands in the background.&lt;br /&gt;
Read more&lt;br /&gt;
SysAdmin&lt;br /&gt;
How to Create Symbolic Link (Symlink) in Linux&lt;br /&gt;
December 4, 2023&lt;br /&gt;
In Linux, symbolic links are used to easily manage and access files. This tutorial covers how to create, manage, and delete links in the Linux terminal using the ln command.&lt;br /&gt;
Read more&lt;br /&gt;
Security SysAdmin&lt;br /&gt;
User Management in Linux&lt;br /&gt;
November 23, 2023&lt;br /&gt;
This article explains how user management in Linux works and outlines the most commonly used commands for managing users.&lt;br /&gt;
Read more&lt;br /&gt;
RECENT POSTS&lt;br /&gt;
&lt;br /&gt;
    How to Use APT Package Manager&lt;br /&gt;
    How to Install Elasticsearch on Ubuntu&lt;br /&gt;
    How to Mount Remote File Systems via SSHFS on macOS&lt;br /&gt;
    Ubuntu Package Managers Overview&lt;br /&gt;
    Nginx Reverse Proxy for Kibana: How to Configure&lt;br /&gt;
&lt;br /&gt;
CATEGORIES&lt;br /&gt;
&lt;br /&gt;
    SysAdmin&lt;br /&gt;
    Virtualization&lt;br /&gt;
    DevOps and Development&lt;br /&gt;
    Security&lt;br /&gt;
    Backup and Recovery&lt;br /&gt;
    Bare Metal Servers&lt;br /&gt;
    Web Servers&lt;br /&gt;
    Networking&lt;br /&gt;
    Databases&lt;br /&gt;
&lt;br /&gt;
COLOCATION&lt;br /&gt;
&lt;br /&gt;
    Phoenix&lt;br /&gt;
    Ashburn&lt;br /&gt;
    Amsterdam&lt;br /&gt;
    Atlanta&lt;br /&gt;
    Belgrade&lt;br /&gt;
    Singapore&lt;br /&gt;
&lt;br /&gt;
PROMOTIONS&lt;br /&gt;
SERVERS&lt;br /&gt;
&lt;br /&gt;
    Dedicated Servers&lt;br /&gt;
    Database Servers&lt;br /&gt;
    Virtualization Servers&lt;br /&gt;
    High Performance Computing (HPC) Servers&lt;br /&gt;
    Dedicated Streaming Servers&lt;br /&gt;
    Dedicated Game Servers&lt;br /&gt;
    Dedicated Storage Servers&lt;br /&gt;
    SQL Server Hosting&lt;br /&gt;
    Dedicated Servers in Amsterdam&lt;br /&gt;
    Cloud Servers in Europe&lt;br /&gt;
    Big Memory Infrastructure&lt;br /&gt;
&lt;br /&gt;
BUY NOW&lt;br /&gt;
CLOUD SERVICES&lt;br /&gt;
&lt;br /&gt;
    Data Security Cloud&lt;br /&gt;
    VPDC&lt;br /&gt;
    Managed Private Cloud&lt;br /&gt;
    Object Storage&lt;br /&gt;
&lt;br /&gt;
SERVERS&lt;br /&gt;
&lt;br /&gt;
    Disaster Recovery&lt;br /&gt;
    Web Hosting Reseller&lt;br /&gt;
    SaaS Hosting&lt;br /&gt;
&lt;br /&gt;
INDUSTRIES&lt;br /&gt;
&lt;br /&gt;
    Web Hosting Providers&lt;br /&gt;
    Legal&lt;br /&gt;
    MSPs &amp;amp; VARs&lt;br /&gt;
    Media Hosting&lt;br /&gt;
    Online Gaming&lt;br /&gt;
    SaaS Hosting Solutions&lt;br /&gt;
    Ecommerce Hosting Solutions&lt;br /&gt;
&lt;br /&gt;
COMPLIANCE&lt;br /&gt;
&lt;br /&gt;
    HIPAA Ready Hosting&lt;br /&gt;
    PCI Compliant Hosting&lt;br /&gt;
&lt;br /&gt;
NEEDS&lt;br /&gt;
&lt;br /&gt;
    Disaster Recovery Solutions&lt;br /&gt;
    High Availability Solutions&lt;br /&gt;
    Cloud Evaluation&lt;br /&gt;
&lt;br /&gt;
COMPANY&lt;br /&gt;
&lt;br /&gt;
    About Us&lt;br /&gt;
    GitHub&lt;br /&gt;
    Blog&lt;br /&gt;
    RFP Template&lt;br /&gt;
    Careers&lt;br /&gt;
&lt;br /&gt;
CONNECT&lt;br /&gt;
&lt;br /&gt;
    Events&lt;br /&gt;
    Press&lt;br /&gt;
    Contact Us&lt;br /&gt;
&lt;br /&gt;
    PhoenixNAP Home&lt;br /&gt;
    Blog&lt;br /&gt;
    Resources&lt;br /&gt;
    Glossary&lt;br /&gt;
    GitHub&lt;br /&gt;
    RFP Template&lt;br /&gt;
&lt;br /&gt;
     Live Chat  Get a Quote  Support | 1-855-330-1509  Sales | 1-877-588-5918 &lt;br /&gt;
&lt;br /&gt;
    Contact Us&lt;br /&gt;
    Legal&lt;br /&gt;
    Privacy Policy&lt;br /&gt;
    Terms of Use&lt;br /&gt;
    DMCA&lt;br /&gt;
    GDPR&lt;br /&gt;
    Sitemap&lt;br /&gt;
&lt;br /&gt;
Privacy Center Do not sell or share my personal information&lt;br /&gt;
©2024 Copyright phoenixNAP | Global IT Services. All Rights Reserved.&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Handleidingen_voor_diverse_applicaties_met_Rocky_9&amp;diff=101</id>
		<title>Handleidingen voor diverse applicaties met Rocky 9</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Handleidingen_voor_diverse_applicaties_met_Rocky_9&amp;diff=101"/>
		<updated>2024-08-25T06:27:36Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Menu =&lt;br /&gt;
&lt;br /&gt;
== Welkom bij mijn verzameling handleidingen: ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mijn kennis van Linux was beperkt, maar door gewoon veel dingen te proberen, leer je snel bij.&lt;br /&gt;
&lt;br /&gt;
Dit gaat het makkelijks als je de beschikking hebt over een (virtual)server of een account bij een grote partij waarbij je op eenvoudige wijze een linus server kunt gebruiken en/of aanmakem.&lt;br /&gt;
&lt;br /&gt;
Ik heb in een thuis omgeving VMware ESXI draaien en kan op die manier snel nieuwe dingen uitproberen.&lt;br /&gt;
&lt;br /&gt;
Als het dan helemaal fout gaat, kun je gewoon opnieuw beginnen.&lt;br /&gt;
&lt;br /&gt;
Ik was in de gelukkige omstandigheden dat ik een vraagbaak inde vorm van een goede vriend achter da hand had.&lt;br /&gt;
&lt;br /&gt;
Hij heeft alle kennis in huis, en als ik er na twee dagen nog niet uit ben, vraag ik hem om mij op weg te helpen.&lt;br /&gt;
&lt;br /&gt;
Ook heeft hij een aantal best practice voorbeelden van installaties, die ik ook hier heb opgenomen.&lt;br /&gt;
&lt;br /&gt;
Ik heb alle topics apart van elkaar gedocumenteerd, en deze zijn eenvoudig via onderstaand menu te bekijken.&lt;br /&gt;
- [[Menu|WireGuard]]&lt;br /&gt;
&lt;br /&gt;
- [[Menu|WireGuard]]&lt;br /&gt;
&lt;br /&gt;
- [[PhpMyAdmin]]&lt;br /&gt;
&lt;br /&gt;
- [[Mariadb|MariaDB]]&lt;br /&gt;
&lt;br /&gt;
- [[Node-red]]&lt;br /&gt;
&lt;br /&gt;
- [[MQTT]]&lt;br /&gt;
&lt;br /&gt;
- [[Wifi via commandline instellen]]&lt;br /&gt;
&lt;br /&gt;
- [[Logging]]&lt;br /&gt;
&lt;br /&gt;
- [[ReadonlyPi]]&lt;br /&gt;
&lt;br /&gt;
- [[Cronjobs]]&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=ReadonlyPi&amp;diff=100</id>
		<title>ReadonlyPi</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=ReadonlyPi&amp;diff=100"/>
		<updated>2024-07-14T20:15:50Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; Overview&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://learn.adafruit.com/read-only-raspberry-pi/overview&lt;br /&gt;
&lt;br /&gt;
RaspberryPi aanpassingen&lt;br /&gt;
&lt;br /&gt;
Voor het omzetten van de dans met wireguard opnieuw starten:&lt;br /&gt;
&lt;br /&gt;
systemctl restart wg-quick@wg0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unlike most microcontroller projects that can simply be switched off when done, computers like the Raspberry Pi require an orderly shutdown procedure…otherwise the storage card may become corrupted and the system will no longer boot.&lt;br /&gt;
&lt;br /&gt;
There are situations where just pulling the plug would certainly be handy, like slideshow or video kiosks, or systems left in the hands of non-technical users. Fortunately recent Raspberry Pi OS releases have a configuration option to make systems more resistant to unplanned power cuts.&lt;br /&gt;
The Concern&lt;br /&gt;
&lt;br /&gt;
Linux—or any substantial computer operating system, Windows and Mac are the same way—behind the scenes they’re frequently writing temporary data to disk (or the SD card with Raspberry Pi). This is why we normally use the shutdown command: every file is put away in a known valid state. But if power is unexpectedly cut, these lingering half-files can render a card unbootable…one can try patching it up, but often there’s no recourse but to wipe the card and reinstall everything.&lt;br /&gt;
The Solution&lt;br /&gt;
&lt;br /&gt;
Recent Rapsberry Pi OS releases have an option to put the /boot partition (where the kernel image and other critical files reside) in a read-only mode. If software installed on this system only performs reading and playback operations (e.g. a slideshow kiosk, a Fadecandy server, a Halloween display), then you can just unplug the system when done. It’s not ideal for read/write tasks like databases, web servers or data logging, but it has a place.&lt;br /&gt;
Before You Begin&lt;br /&gt;
&lt;br /&gt;
    This works with Raspberry Pi OS and close derivatives (e.g. RetroPie), but might not work with other distributions.&lt;br /&gt;
    Setting up read-only mode should be the very last step before deploying a project. Get all your code and data on the system, get software auto-starting as needed, test it normally with the usual boot and shutdown methodology. It’s easier up-front. Once you’re 100% confident in its operation, then configure the system for read-only boot.&lt;br /&gt;
    Back up the contents of your SD card first. We’ve tested on a couple versions of Raspbian, but maybe something’s changed, or has been overlooked, and could leave the Pi in a weird intermediate state.&lt;br /&gt;
&lt;br /&gt;
Enabling Read-Only /boot&lt;br /&gt;
&lt;br /&gt;
We assume that you have a Pi booted and on a network…like mentioned above, everything already configured and fully functional (and backed up) before taking this step. We have other guides covering the very basics of getting a Raspberry Pi started.&lt;br /&gt;
Using the Desktop/GUI “Full” OS&lt;br /&gt;
&lt;br /&gt;
You’ll find this setting in the Raspberry Pi Configuration tool. From the Raspberry menu at the top-left…&lt;br /&gt;
&lt;br /&gt;
Pi→Preferences→Raspberry Pi Configuration&lt;br /&gt;
&lt;br /&gt;
    learn_raspberry_pi_gui-1.png&lt;br /&gt;
    learn_raspberry_pi_gui-1.png&lt;br /&gt;
    learn_raspberry_pi_gui-2.png&lt;br /&gt;
    learn_raspberry_pi_gui-3.png&lt;br /&gt;
    learn_raspberry_pi_gui-4.png&lt;br /&gt;
&lt;br /&gt;
Go to the “Performance” tab and you’ll see an option “Overlay File System.” Click the “Configure…” button.&lt;br /&gt;
&lt;br /&gt;
Select “Overlay: Enabled” and “Boot Partition: Read-only.”&lt;br /&gt;
&lt;br /&gt;
Click “OK” and wait while the system works. It may take a minute or more to complete. This is normal.&lt;br /&gt;
&lt;br /&gt;
Reboot when prompted.&lt;br /&gt;
Using the “Lite” Command-Line OS&lt;br /&gt;
&lt;br /&gt;
These options can be found in the raspi-config tool, which must be run as root:&lt;br /&gt;
Download File&lt;br /&gt;
Copy Code&lt;br /&gt;
&lt;br /&gt;
sudo raspi-config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    learn_raspberry_pi_cmdline-1.png&lt;br /&gt;
    learn_raspberry_pi_cmdline-1.png&lt;br /&gt;
    learn_raspberry_pi_cmdline-2.png&lt;br /&gt;
    learn_raspberry_pi_cmdline-3.png&lt;br /&gt;
    learn_raspberry_pi_cmdline-4.png&lt;br /&gt;
&lt;br /&gt;
Navigate down to “Performance Options” and then “Overlay File System.” Select “Yes” to both the enable and write-protect questions.&lt;br /&gt;
&lt;br /&gt;
It may take a minute or more while the system works, this is normal. Tab to the “Finish” button and reboot when prompted.&lt;br /&gt;
For Both&lt;br /&gt;
&lt;br /&gt;
You’re done! Now the /boot partition is safely locked. If you need to access something there though, like the config.txt file, or a major system update, instructions to temporarily enable write access are given below.&lt;br /&gt;
&lt;br /&gt;
With each new OS release, it’s normal that some configuration options may move to different menus or positions. If you can’t find it where shown, check under the other top-level menu options…even if moved, the name will likely remain similar.&lt;br /&gt;
Restoring Read/Write Access&lt;br /&gt;
&lt;br /&gt;
If you need to temporarily enable read/write access, as when editing tricky configuration settings in /boot/config.txt, or major system updates affecting the kernel or device tree files, this can be done from the command line (if using “full” Raspbian with a GUI, open a terminal window):&lt;br /&gt;
Download File&lt;br /&gt;
Copy Code&lt;br /&gt;
&lt;br /&gt;
sudo mount -o remount,rw /boot&lt;br /&gt;
&lt;br /&gt;
Perform your edits or upgrades, then reboot the system (via Pi→Shutdown with the GUI, or sudo reboot from the command line). It will be back in its read-only state.&lt;br /&gt;
&lt;br /&gt;
If you need to permanently restore read/write access, you must first use the temporary step above, then can navigate to the same GUI or raspi-config settings, selecting “Read-write” for the GUI option, or “No” for the raspi-config write-protect question. Then reboot and the system’s back to normal, with permanent read/write access.&lt;br /&gt;
If you have enabled read/write access to /boot, whether temporarily or permanently, always wrap up your session with an orderly shutdown or reboot.&lt;br /&gt;
You’re Not Finished Yet&lt;br /&gt;
&lt;br /&gt;
Test the modified system extensively to make sure that the system boots and your application runs as intended. If it doesn’t…does the software you’re using rely on temporary files in the /boot partition? Maybe it can be adjusted.&lt;br /&gt;
&lt;br /&gt;
Now make an image of the SD card (using dd or Apple Pi Baker or whatever your backup tool of preference) and, if it’s a critical application, burn at least one spare. There are other ways cards can go bad…static, brown-outs, falling out and getting lost…this read-only setup won’t always save you. SD cards are cheap now! Spares help if you’ve left a system in someone else’s care (let’s say a museum kiosk) and it fails for some reason, you can ask them to just swap out the card until you can get there to troubleshoot. I know at least one Burning Man project rendered useless in the first few minutes of the event because their one and only card fell out and was lost on the playa.&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=ReadonlyPi&amp;diff=99</id>
		<title>ReadonlyPi</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=ReadonlyPi&amp;diff=99"/>
		<updated>2024-07-14T19:57:45Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; Overview&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://learn.adafruit.com/read-only-raspberry-pi/overview&lt;br /&gt;
&lt;br /&gt;
Unlike most microcontroller projects that can simply be switched off when done, computers like the Raspberry Pi require an orderly shutdown procedure…otherwise the storage card may become corrupted and the system will no longer boot.&lt;br /&gt;
&lt;br /&gt;
There are situations where just pulling the plug would certainly be handy, like slideshow or video kiosks, or systems left in the hands of non-technical users. Fortunately recent Raspberry Pi OS releases have a configuration option to make systems more resistant to unplanned power cuts.&lt;br /&gt;
The Concern&lt;br /&gt;
&lt;br /&gt;
Linux—or any substantial computer operating system, Windows and Mac are the same way—behind the scenes they’re frequently writing temporary data to disk (or the SD card with Raspberry Pi). This is why we normally use the shutdown command: every file is put away in a known valid state. But if power is unexpectedly cut, these lingering half-files can render a card unbootable…one can try patching it up, but often there’s no recourse but to wipe the card and reinstall everything.&lt;br /&gt;
The Solution&lt;br /&gt;
&lt;br /&gt;
Recent Rapsberry Pi OS releases have an option to put the /boot partition (where the kernel image and other critical files reside) in a read-only mode. If software installed on this system only performs reading and playback operations (e.g. a slideshow kiosk, a Fadecandy server, a Halloween display), then you can just unplug the system when done. It’s not ideal for read/write tasks like databases, web servers or data logging, but it has a place.&lt;br /&gt;
Before You Begin&lt;br /&gt;
&lt;br /&gt;
    This works with Raspberry Pi OS and close derivatives (e.g. RetroPie), but might not work with other distributions.&lt;br /&gt;
    Setting up read-only mode should be the very last step before deploying a project. Get all your code and data on the system, get software auto-starting as needed, test it normally with the usual boot and shutdown methodology. It’s easier up-front. Once you’re 100% confident in its operation, then configure the system for read-only boot.&lt;br /&gt;
    Back up the contents of your SD card first. We’ve tested on a couple versions of Raspbian, but maybe something’s changed, or has been overlooked, and could leave the Pi in a weird intermediate state.&lt;br /&gt;
&lt;br /&gt;
Enabling Read-Only /boot&lt;br /&gt;
&lt;br /&gt;
We assume that you have a Pi booted and on a network…like mentioned above, everything already configured and fully functional (and backed up) before taking this step. We have other guides covering the very basics of getting a Raspberry Pi started.&lt;br /&gt;
Using the Desktop/GUI “Full” OS&lt;br /&gt;
&lt;br /&gt;
You’ll find this setting in the Raspberry Pi Configuration tool. From the Raspberry menu at the top-left…&lt;br /&gt;
&lt;br /&gt;
Pi→Preferences→Raspberry Pi Configuration&lt;br /&gt;
&lt;br /&gt;
    learn_raspberry_pi_gui-1.png&lt;br /&gt;
    learn_raspberry_pi_gui-1.png&lt;br /&gt;
    learn_raspberry_pi_gui-2.png&lt;br /&gt;
    learn_raspberry_pi_gui-3.png&lt;br /&gt;
    learn_raspberry_pi_gui-4.png&lt;br /&gt;
&lt;br /&gt;
Go to the “Performance” tab and you’ll see an option “Overlay File System.” Click the “Configure…” button.&lt;br /&gt;
&lt;br /&gt;
Select “Overlay: Enabled” and “Boot Partition: Read-only.”&lt;br /&gt;
&lt;br /&gt;
Click “OK” and wait while the system works. It may take a minute or more to complete. This is normal.&lt;br /&gt;
&lt;br /&gt;
Reboot when prompted.&lt;br /&gt;
Using the “Lite” Command-Line OS&lt;br /&gt;
&lt;br /&gt;
These options can be found in the raspi-config tool, which must be run as root:&lt;br /&gt;
Download File&lt;br /&gt;
Copy Code&lt;br /&gt;
&lt;br /&gt;
sudo raspi-config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    learn_raspberry_pi_cmdline-1.png&lt;br /&gt;
    learn_raspberry_pi_cmdline-1.png&lt;br /&gt;
    learn_raspberry_pi_cmdline-2.png&lt;br /&gt;
    learn_raspberry_pi_cmdline-3.png&lt;br /&gt;
    learn_raspberry_pi_cmdline-4.png&lt;br /&gt;
&lt;br /&gt;
Navigate down to “Performance Options” and then “Overlay File System.” Select “Yes” to both the enable and write-protect questions.&lt;br /&gt;
&lt;br /&gt;
It may take a minute or more while the system works, this is normal. Tab to the “Finish” button and reboot when prompted.&lt;br /&gt;
For Both&lt;br /&gt;
&lt;br /&gt;
You’re done! Now the /boot partition is safely locked. If you need to access something there though, like the config.txt file, or a major system update, instructions to temporarily enable write access are given below.&lt;br /&gt;
&lt;br /&gt;
With each new OS release, it’s normal that some configuration options may move to different menus or positions. If you can’t find it where shown, check under the other top-level menu options…even if moved, the name will likely remain similar.&lt;br /&gt;
Restoring Read/Write Access&lt;br /&gt;
&lt;br /&gt;
If you need to temporarily enable read/write access, as when editing tricky configuration settings in /boot/config.txt, or major system updates affecting the kernel or device tree files, this can be done from the command line (if using “full” Raspbian with a GUI, open a terminal window):&lt;br /&gt;
Download File&lt;br /&gt;
Copy Code&lt;br /&gt;
&lt;br /&gt;
sudo mount -o remount,rw /boot&lt;br /&gt;
&lt;br /&gt;
Perform your edits or upgrades, then reboot the system (via Pi→Shutdown with the GUI, or sudo reboot from the command line). It will be back in its read-only state.&lt;br /&gt;
&lt;br /&gt;
If you need to permanently restore read/write access, you must first use the temporary step above, then can navigate to the same GUI or raspi-config settings, selecting “Read-write” for the GUI option, or “No” for the raspi-config write-protect question. Then reboot and the system’s back to normal, with permanent read/write access.&lt;br /&gt;
If you have enabled read/write access to /boot, whether temporarily or permanently, always wrap up your session with an orderly shutdown or reboot.&lt;br /&gt;
You’re Not Finished Yet&lt;br /&gt;
&lt;br /&gt;
Test the modified system extensively to make sure that the system boots and your application runs as intended. If it doesn’t…does the software you’re using rely on temporary files in the /boot partition? Maybe it can be adjusted.&lt;br /&gt;
&lt;br /&gt;
Now make an image of the SD card (using dd or Apple Pi Baker or whatever your backup tool of preference) and, if it’s a critical application, burn at least one spare. There are other ways cards can go bad…static, brown-outs, falling out and getting lost…this read-only setup won’t always save you. SD cards are cheap now! Spares help if you’ve left a system in someone else’s care (let’s say a museum kiosk) and it fails for some reason, you can ask them to just swap out the card until you can get there to troubleshoot. I know at least one Burning Man project rendered useless in the first few minutes of the event because their one and only card fell out and was lost on the playa.&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=ReadonlyPi&amp;diff=98</id>
		<title>ReadonlyPi</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=ReadonlyPi&amp;diff=98"/>
		<updated>2024-06-30T16:01:10Z</updated>

		<summary type="html">&lt;p&gt;Erwin: Nieuwe pagina aangemaakt met ' Overview  Unlike most microcontroller projects that can simply be switched off when done, computers like the Raspberry Pi require an orderly shutdown procedure…otherwise the storage card may become corrupted and the system will no longer boot.  There are situations where just pulling the plug would certainly be handy, like slideshow or video kiosks, or systems left in the hands of non-technical users. Fortunately recent Raspberry Pi OS releases have a confi...'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; Overview&lt;br /&gt;
&lt;br /&gt;
Unlike most microcontroller projects that can simply be switched off when done, computers like the Raspberry Pi require an orderly shutdown procedure…otherwise the storage card may become corrupted and the system will no longer boot.&lt;br /&gt;
&lt;br /&gt;
There are situations where just pulling the plug would certainly be handy, like slideshow or video kiosks, or systems left in the hands of non-technical users. Fortunately recent Raspberry Pi OS releases have a configuration option to make systems more resistant to unplanned power cuts.&lt;br /&gt;
The Concern&lt;br /&gt;
&lt;br /&gt;
Linux—or any substantial computer operating system, Windows and Mac are the same way—behind the scenes they’re frequently writing temporary data to disk (or the SD card with Raspberry Pi). This is why we normally use the shutdown command: every file is put away in a known valid state. But if power is unexpectedly cut, these lingering half-files can render a card unbootable…one can try patching it up, but often there’s no recourse but to wipe the card and reinstall everything.&lt;br /&gt;
The Solution&lt;br /&gt;
&lt;br /&gt;
Recent Rapsberry Pi OS releases have an option to put the /boot partition (where the kernel image and other critical files reside) in a read-only mode. If software installed on this system only performs reading and playback operations (e.g. a slideshow kiosk, a Fadecandy server, a Halloween display), then you can just unplug the system when done. It’s not ideal for read/write tasks like databases, web servers or data logging, but it has a place.&lt;br /&gt;
Before You Begin&lt;br /&gt;
&lt;br /&gt;
    This works with Raspberry Pi OS and close derivatives (e.g. RetroPie), but might not work with other distributions.&lt;br /&gt;
    Setting up read-only mode should be the very last step before deploying a project. Get all your code and data on the system, get software auto-starting as needed, test it normally with the usual boot and shutdown methodology. It’s easier up-front. Once you’re 100% confident in its operation, then configure the system for read-only boot.&lt;br /&gt;
    Back up the contents of your SD card first. We’ve tested on a couple versions of Raspbian, but maybe something’s changed, or has been overlooked, and could leave the Pi in a weird intermediate state.&lt;br /&gt;
&lt;br /&gt;
Enabling Read-Only /boot&lt;br /&gt;
&lt;br /&gt;
We assume that you have a Pi booted and on a network…like mentioned above, everything already configured and fully functional (and backed up) before taking this step. We have other guides covering the very basics of getting a Raspberry Pi started.&lt;br /&gt;
Using the Desktop/GUI “Full” OS&lt;br /&gt;
&lt;br /&gt;
You’ll find this setting in the Raspberry Pi Configuration tool. From the Raspberry menu at the top-left…&lt;br /&gt;
&lt;br /&gt;
Pi→Preferences→Raspberry Pi Configuration&lt;br /&gt;
&lt;br /&gt;
    learn_raspberry_pi_gui-1.png&lt;br /&gt;
    learn_raspberry_pi_gui-1.png&lt;br /&gt;
    learn_raspberry_pi_gui-2.png&lt;br /&gt;
    learn_raspberry_pi_gui-3.png&lt;br /&gt;
    learn_raspberry_pi_gui-4.png&lt;br /&gt;
&lt;br /&gt;
Go to the “Performance” tab and you’ll see an option “Overlay File System.” Click the “Configure…” button.&lt;br /&gt;
&lt;br /&gt;
Select “Overlay: Enabled” and “Boot Partition: Read-only.”&lt;br /&gt;
&lt;br /&gt;
Click “OK” and wait while the system works. It may take a minute or more to complete. This is normal.&lt;br /&gt;
&lt;br /&gt;
Reboot when prompted.&lt;br /&gt;
Using the “Lite” Command-Line OS&lt;br /&gt;
&lt;br /&gt;
These options can be found in the raspi-config tool, which must be run as root:&lt;br /&gt;
Download File&lt;br /&gt;
Copy Code&lt;br /&gt;
&lt;br /&gt;
sudo raspi-config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    learn_raspberry_pi_cmdline-1.png&lt;br /&gt;
    learn_raspberry_pi_cmdline-1.png&lt;br /&gt;
    learn_raspberry_pi_cmdline-2.png&lt;br /&gt;
    learn_raspberry_pi_cmdline-3.png&lt;br /&gt;
    learn_raspberry_pi_cmdline-4.png&lt;br /&gt;
&lt;br /&gt;
Navigate down to “Performance Options” and then “Overlay File System.” Select “Yes” to both the enable and write-protect questions.&lt;br /&gt;
&lt;br /&gt;
It may take a minute or more while the system works, this is normal. Tab to the “Finish” button and reboot when prompted.&lt;br /&gt;
For Both&lt;br /&gt;
&lt;br /&gt;
You’re done! Now the /boot partition is safely locked. If you need to access something there though, like the config.txt file, or a major system update, instructions to temporarily enable write access are given below.&lt;br /&gt;
&lt;br /&gt;
With each new OS release, it’s normal that some configuration options may move to different menus or positions. If you can’t find it where shown, check under the other top-level menu options…even if moved, the name will likely remain similar.&lt;br /&gt;
Restoring Read/Write Access&lt;br /&gt;
&lt;br /&gt;
If you need to temporarily enable read/write access, as when editing tricky configuration settings in /boot/config.txt, or major system updates affecting the kernel or device tree files, this can be done from the command line (if using “full” Raspbian with a GUI, open a terminal window):&lt;br /&gt;
Download File&lt;br /&gt;
Copy Code&lt;br /&gt;
&lt;br /&gt;
sudo mount -o remount,rw /boot&lt;br /&gt;
&lt;br /&gt;
Perform your edits or upgrades, then reboot the system (via Pi→Shutdown with the GUI, or sudo reboot from the command line). It will be back in its read-only state.&lt;br /&gt;
&lt;br /&gt;
If you need to permanently restore read/write access, you must first use the temporary step above, then can navigate to the same GUI or raspi-config settings, selecting “Read-write” for the GUI option, or “No” for the raspi-config write-protect question. Then reboot and the system’s back to normal, with permanent read/write access.&lt;br /&gt;
If you have enabled read/write access to /boot, whether temporarily or permanently, always wrap up your session with an orderly shutdown or reboot.&lt;br /&gt;
You’re Not Finished Yet&lt;br /&gt;
&lt;br /&gt;
Test the modified system extensively to make sure that the system boots and your application runs as intended. If it doesn’t…does the software you’re using rely on temporary files in the /boot partition? Maybe it can be adjusted.&lt;br /&gt;
&lt;br /&gt;
Now make an image of the SD card (using dd or Apple Pi Baker or whatever your backup tool of preference) and, if it’s a critical application, burn at least one spare. There are other ways cards can go bad…static, brown-outs, falling out and getting lost…this read-only setup won’t always save you. SD cards are cheap now! Spares help if you’ve left a system in someone else’s care (let’s say a museum kiosk) and it fails for some reason, you can ask them to just swap out the card until you can get there to troubleshoot. I know at least one Burning Man project rendered useless in the first few minutes of the event because their one and only card fell out and was lost on the playa.&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Handleidingen_voor_diverse_applicaties_met_Rocky_9&amp;diff=97</id>
		<title>Handleidingen voor diverse applicaties met Rocky 9</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Handleidingen_voor_diverse_applicaties_met_Rocky_9&amp;diff=97"/>
		<updated>2024-06-30T15:59:38Z</updated>

		<summary type="html">&lt;p&gt;Erwin: /* Menu */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Menu =&lt;br /&gt;
&lt;br /&gt;
== Welkom bij mijn verzameling handleidingen: ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mijn kennis van Linux was beperkt, maar door gewoon veel dingen te proberen, leer je snel bij.&lt;br /&gt;
&lt;br /&gt;
Dit gaat het makkelijks als je de beschikking hebt over een (virtual)server of een account bij een grote partij waarbij je op eenvoudige wijze een linus server kunt gebruiken en/of aanmakem.&lt;br /&gt;
&lt;br /&gt;
Ik heb in een thuis omgeving VMware ESXI draaien en kan op die manier snel nieuwe dingen uitproberen.&lt;br /&gt;
&lt;br /&gt;
Als het dan helemaal fout gaat, kun je gewoon opnieuw beginnen.&lt;br /&gt;
&lt;br /&gt;
Ik was in de gelukkige omstandigheden dat ik een vraagbaak inde vorm van een goede vriend achter da hand had.&lt;br /&gt;
&lt;br /&gt;
Hij heeft alle kennis in huis, en als ik er na twee dagen nog niet uit ben, vraag ik hem om mij op weg te helpen.&lt;br /&gt;
&lt;br /&gt;
Ook heeft hij een aantal best practice voorbeelden van installaties, die ik ook hier heb opgenomen.&lt;br /&gt;
&lt;br /&gt;
Ik heb alle topics apart van elkaar gedocumenteerd, en deze zijn eenvoudig via onderstaand menu te bekijken.&lt;br /&gt;
- [[Menu|WireGuard]]&lt;br /&gt;
&lt;br /&gt;
- [[Menu|WireGuard]]&lt;br /&gt;
&lt;br /&gt;
- [[PhpMyAdmin]]&lt;br /&gt;
&lt;br /&gt;
- [[Mariadb|MariaDB]]&lt;br /&gt;
&lt;br /&gt;
- [[Node-red]]&lt;br /&gt;
&lt;br /&gt;
- [[MQTT]]&lt;br /&gt;
&lt;br /&gt;
- [[Wifi via commandline instellen]]&lt;br /&gt;
&lt;br /&gt;
- [[Logging]]&lt;br /&gt;
&lt;br /&gt;
- [[ReadonlyPi]]&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Logging&amp;diff=96</id>
		<title>Logging</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Logging&amp;diff=96"/>
		<updated>2024-02-22T08:15:02Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Logging uitschakelen&lt;br /&gt;
&lt;br /&gt;
If you are not interested in the logs you can switch a lot off using a log configuration setting.&lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/rsyslog.conf and just after the section starting&lt;br /&gt;
&lt;br /&gt;
.###############&lt;br /&gt;
&lt;br /&gt;
.#### RULES ####&lt;br /&gt;
&lt;br /&gt;
.###############&lt;br /&gt;
&lt;br /&gt;
add the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;*.*     ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to be more fine-grained you will need to read the file comments.&lt;br /&gt;
&lt;br /&gt;
Do not forget to restart rsyslog daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service rsyslog restart&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Logging&amp;diff=95</id>
		<title>Logging</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Logging&amp;diff=95"/>
		<updated>2024-02-22T08:14:55Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Logging uitschakelen&lt;br /&gt;
&lt;br /&gt;
If you are not interested in the logs you can switch a lot off using a log configuration setting.&lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/rsyslog.conf and just after the section starting&lt;br /&gt;
&lt;br /&gt;
.###############&lt;br /&gt;
.#### RULES ####&lt;br /&gt;
.###############&lt;br /&gt;
&lt;br /&gt;
add the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;*.*     ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to be more fine-grained you will need to read the file comments.&lt;br /&gt;
&lt;br /&gt;
Do not forget to restart rsyslog daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service rsyslog restart&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Logging&amp;diff=94</id>
		<title>Logging</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Logging&amp;diff=94"/>
		<updated>2024-02-22T08:14:41Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Logging uitschakelen&lt;br /&gt;
&lt;br /&gt;
If you are not interested in the logs you can switch a lot off using a log configuration setting.&lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/rsyslog.conf and just after the section starting&lt;br /&gt;
&lt;br /&gt;
{_}###############&lt;br /&gt;
{_}#### RULES ####&lt;br /&gt;
{_}###############&lt;br /&gt;
&lt;br /&gt;
add the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;*.*     ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to be more fine-grained you will need to read the file comments.&lt;br /&gt;
&lt;br /&gt;
Do not forget to restart rsyslog daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service rsyslog restart&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Logging&amp;diff=93</id>
		<title>Logging</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Logging&amp;diff=93"/>
		<updated>2024-02-22T08:14:15Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Logging uitschakelen&lt;br /&gt;
&lt;br /&gt;
If you are not interested in the logs you can switch a lot off using a log configuration setting.&lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/rsyslog.conf and just after the section starting&lt;br /&gt;
&lt;br /&gt;
...###############...&lt;br /&gt;
#### RULES ####&lt;br /&gt;
###############&lt;br /&gt;
&lt;br /&gt;
add the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;*.*     ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to be more fine-grained you will need to read the file comments.&lt;br /&gt;
&lt;br /&gt;
Do not forget to restart rsyslog daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service rsyslog restart&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Logging&amp;diff=92</id>
		<title>Logging</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Logging&amp;diff=92"/>
		<updated>2024-02-22T08:13:47Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Logging uitschakelen&lt;br /&gt;
&lt;br /&gt;
If you are not interested in the logs you can switch a lot off using a log configuration setting.&lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/rsyslog.conf and just after the section starting&lt;br /&gt;
&lt;br /&gt;
###############&lt;br /&gt;
#### RULES ####&lt;br /&gt;
###############&lt;br /&gt;
&lt;br /&gt;
add the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;_*.*     ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to be more fine-grained you will need to read the file comments.&lt;br /&gt;
&lt;br /&gt;
Do not forget to restart rsyslog daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service rsyslog restart&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Logging&amp;diff=91</id>
		<title>Logging</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Logging&amp;diff=91"/>
		<updated>2024-02-22T08:10:52Z</updated>

		<summary type="html">&lt;p&gt;Erwin: Nieuwe pagina aangemaakt met 'Logging uitschakelen  If you are not interested in the logs you can switch a lot off using a log configuration setting.  Edit the file /etc/rsyslog.conf and just after the section starting  ############### #### RULES #### ###############  add the following line.  &amp;lt;code&amp;gt;*.*     ~&amp;lt;/code&amp;gt;  If you want to be more fine-grained you will need to read the file comments.  Do not forget to restart rsyslog daemon:  &amp;lt;code&amp;gt;sudo service rsyslog restart&amp;lt;/code&amp;gt;'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Logging uitschakelen&lt;br /&gt;
&lt;br /&gt;
If you are not interested in the logs you can switch a lot off using a log configuration setting.&lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/rsyslog.conf and just after the section starting&lt;br /&gt;
&lt;br /&gt;
###############&lt;br /&gt;
#### RULES ####&lt;br /&gt;
###############&lt;br /&gt;
&lt;br /&gt;
add the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;*.*     ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to be more fine-grained you will need to read the file comments.&lt;br /&gt;
&lt;br /&gt;
Do not forget to restart rsyslog daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service rsyslog restart&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Handleidingen_voor_diverse_applicaties_met_Rocky_9&amp;diff=90</id>
		<title>Handleidingen voor diverse applicaties met Rocky 9</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Handleidingen_voor_diverse_applicaties_met_Rocky_9&amp;diff=90"/>
		<updated>2024-02-22T08:09:52Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Menu =&lt;br /&gt;
&lt;br /&gt;
== Welkom bij mijn verzameling handleidingen: ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mijn kennis van Linux was beperkt, maar door gewoon veel dingen te proberen, leer je snel bij.&lt;br /&gt;
&lt;br /&gt;
Dit gaat het makkelijks als je de beschikking hebt over een (virtual)server of een account bij een grote partij waarbij je op eenvoudige wijze een linus server kunt gebruiken en/of aanmakem.&lt;br /&gt;
&lt;br /&gt;
Ik heb in een thuis omgeving VMware ESXI draaien en kan op die manier snel nieuwe dingen uitproberen.&lt;br /&gt;
&lt;br /&gt;
Als het dan helemaal fout gaat, kun je gewoon opnieuw beginnen.&lt;br /&gt;
&lt;br /&gt;
Ik was in de gelukkige omstandigheden dat ik een vraagbaak inde vorm van een goede vriend achter da hand had.&lt;br /&gt;
&lt;br /&gt;
Hij heeft alle kennis in huis, en als ik er na twee dagen nog niet uit ben, vraag ik hem om mij op weg te helpen.&lt;br /&gt;
&lt;br /&gt;
Ook heeft hij een aantal best practice voorbeelden van installaties, die ik ook hier heb opgenomen.&lt;br /&gt;
&lt;br /&gt;
Ik heb alle topics apart van elkaar gedocumenteerd, en deze zijn eenvoudig via onderstaand menu te bekijken.&lt;br /&gt;
- [[Menu|WireGuard]]&lt;br /&gt;
&lt;br /&gt;
- [[Menu|WireGuard]]&lt;br /&gt;
&lt;br /&gt;
- [[PhpMyAdmin]]&lt;br /&gt;
&lt;br /&gt;
- [[Mariadb|MariaDB]]&lt;br /&gt;
&lt;br /&gt;
- [[Node-red]]&lt;br /&gt;
&lt;br /&gt;
- [[MQTT]]&lt;br /&gt;
&lt;br /&gt;
- [[Wifi via commandline instellen]]&lt;br /&gt;
&lt;br /&gt;
- [[Logging]]&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Handleidingen_voor_diverse_applicaties_met_Rocky_9&amp;diff=89</id>
		<title>Handleidingen voor diverse applicaties met Rocky 9</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Handleidingen_voor_diverse_applicaties_met_Rocky_9&amp;diff=89"/>
		<updated>2024-02-22T08:09:39Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Menu =&lt;br /&gt;
&lt;br /&gt;
== Welkom bij mijn verzameling handleidingen: ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mijn kennis van Linux was beperkt, maar door gewoon veel dingen te proberen, leer je snel bij.&lt;br /&gt;
&lt;br /&gt;
Dit gaat het makkelijks als je de beschikking hebt over een (virtual)server of een account bij een grote partij waarbij je op eenvoudige wijze een linus server kunt gebruiken en/of aanmakem.&lt;br /&gt;
&lt;br /&gt;
Ik heb in een thuis omgeving VMware ESXI draaien en kan op die manier snel nieuwe dingen uitproberen.&lt;br /&gt;
&lt;br /&gt;
Als het dan helemaal fout gaat, kun je gewoon opnieuw beginnen.&lt;br /&gt;
&lt;br /&gt;
Ik was in de gelukkige omstandigheden dat ik een vraagbaak inde vorm van een goede vriend achter da hand had.&lt;br /&gt;
&lt;br /&gt;
Hij heeft alle kennis in huis, en als ik er na twee dagen nog niet uit ben, vraag ik hem om mij op weg te helpen.&lt;br /&gt;
&lt;br /&gt;
Ook heeft hij een aantal best practice voorbeelden van installaties, die ik ook hier heb opgenomen.&lt;br /&gt;
&lt;br /&gt;
Ik heb alle topics apart van elkaar gedocumenteerd, en deze zijn eenvoudig via onderstaand menu te bekijken.&lt;br /&gt;
- [[Menu|WireGuard]]&lt;br /&gt;
&lt;br /&gt;
- [[Menu|WireGuard]]&lt;br /&gt;
&lt;br /&gt;
- [[PhpMyAdmin]]&lt;br /&gt;
&lt;br /&gt;
- [[Mariadb|MariaDB]]&lt;br /&gt;
&lt;br /&gt;
- [[Node-red]]&lt;br /&gt;
&lt;br /&gt;
- [[MQTT]]&lt;br /&gt;
&lt;br /&gt;
- [[Wifi via commandline instellen]]&lt;br /&gt;
&lt;br /&gt;
-[[logging]]&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Mariadb&amp;diff=88</id>
		<title>Mariadb</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Mariadb&amp;diff=88"/>
		<updated>2024-02-22T08:01:18Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Hoofdpagina|Menu]] [[WireGuard]]  [[PhpMyAdmin]]&lt;br /&gt;
&lt;br /&gt;
== MariaDB Installeren ==&lt;br /&gt;
Om gebruik te maken van phpMyAdmin moet je wel een database hebben.&lt;br /&gt;
&lt;br /&gt;
Om deze te installeren doe je het volgende:&lt;br /&gt;
 &amp;lt;code&amp;gt;sudo dnf install mariadb-server mariadb&amp;lt;/code&amp;gt;&lt;br /&gt;
Dependency Tree:&lt;br /&gt;
 Transaction Summary&lt;br /&gt;
 ================================================================================&lt;br /&gt;
 Install  13 Packages&lt;br /&gt;
 &lt;br /&gt;
 Total download size: 18 M&lt;br /&gt;
 Installed size: 107 M&lt;br /&gt;
 Is this ok [y/N]: y&lt;br /&gt;
Once installed, start and enable MariaDB the service:&lt;br /&gt;
 &amp;lt;code&amp;gt;sudo systemctl enable --now mariadb&amp;lt;/code&amp;gt;&lt;br /&gt;
Verify if the service is running:&lt;br /&gt;
 $ systemctl status mariadb&lt;br /&gt;
 ● mariadb.service - MariaDB 10.5 database server&lt;br /&gt;
      Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)&lt;br /&gt;
      Active: active (running) since Sat 2022-07-23 10:05:47 CEST; 2s ago&lt;br /&gt;
        Docs: man:mariadbd(8)&lt;br /&gt;
              &amp;lt;nowiki&amp;gt;https://mariadb.com/kb/en/library/systemd/&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
     Process: 18153 ExecStartPre=/usr/libexec/mariadb-check-socket (code=exited, status=0/SUCCESS)&lt;br /&gt;
     Process: 18175 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)&lt;br /&gt;
     Process: 20589 ExecStartPost=/usr/libexec/mariadb-check-upgrade (code=exited, status=0/SUCCESS)&lt;br /&gt;
    Main PID: 20448 (mariadbd)&lt;br /&gt;
      Status: &amp;quot;Taking your SQL requests now...&amp;quot;&lt;br /&gt;
       Tasks: 12 (limit: 23441)&lt;br /&gt;
      Memory: 78.5M&lt;br /&gt;
         CPU: 268ms&lt;br /&gt;
      CGroup: /system.slice/mariadb.service&lt;br /&gt;
              └─20448 /usr/libexec/mariadbd --basedir=/usr&lt;br /&gt;
&lt;br /&gt;
== #2. Using MariaDB on Rocky Linux 9|AlmaLinux 9 ==&lt;br /&gt;
Once installed MariaDB/MySQL databases can be used. First, secure the installation by setting a password for the root user.&lt;br /&gt;
 &amp;lt;code&amp;gt;sudo mysql_secure_installation&amp;lt;/code&amp;gt;&lt;br /&gt;
Proceed as shown: On MariaDB:&lt;br /&gt;
 NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB&lt;br /&gt;
       SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!&lt;br /&gt;
 &lt;br /&gt;
 In order to log into MariaDB to secure it, we'll need the current&lt;br /&gt;
 password for the root user. If you've just installed MariaDB, and&lt;br /&gt;
 haven't set the root password yet, you should just press enter here.&lt;br /&gt;
 &lt;br /&gt;
 Enter current password for root (enter for none): Press_Enter&lt;br /&gt;
 OK, successfully used password, moving on...&lt;br /&gt;
 &lt;br /&gt;
 Setting the root password or using the unix_socket ensures that nobody&lt;br /&gt;
 can log into the MariaDB root user without the proper authorisation.&lt;br /&gt;
 &lt;br /&gt;
 You already have your root account protected, so you can safely answer 'n'.&lt;br /&gt;
 &lt;br /&gt;
 Switch to unix_socket authentication [Y/n] y&lt;br /&gt;
 &lt;br /&gt;
 You already have your root account protected, so you can safely answer 'n'.&lt;br /&gt;
 &lt;br /&gt;
 Change the root password? [Y/n] y&lt;br /&gt;
 New password: &lt;br /&gt;
 Re-enter new password: &lt;br /&gt;
 Password updated successfully!&lt;br /&gt;
 .....&lt;br /&gt;
 Remove anonymous users? [Y/n] y&lt;br /&gt;
 ....&lt;br /&gt;
 Disallow root login remotely? [Y/n] y&lt;br /&gt;
 ...&lt;br /&gt;
 Remove test database and access to it? [Y/n] y&lt;br /&gt;
 ....&lt;br /&gt;
 Reload privilege tables now? [Y/n] y&lt;br /&gt;
 All done!  If you've completed all of the above steps, your MariaDB&lt;br /&gt;
 installation should now be secure.&lt;br /&gt;
 &lt;br /&gt;
 Thanks for using MariaDB!&lt;br /&gt;
Now login using the created root password:&lt;br /&gt;
 $ mysql -u root -p&lt;br /&gt;
 Enter password: &lt;br /&gt;
 Welcome to the MySQL monitor.  Commands end with ; or \g.&lt;br /&gt;
 Your MySQL connection id is 10&lt;br /&gt;
 Server version: 8.0.28 Source distribution&lt;br /&gt;
 &lt;br /&gt;
 Copyright (c) 2000, 2022, Oracle and/or its affiliates.&lt;br /&gt;
 &lt;br /&gt;
 Oracle is a registered trademark of Oracle Corporation and/or its&lt;br /&gt;
 affiliates. Other names may be trademarks of their respective&lt;br /&gt;
 owners.&lt;br /&gt;
 &lt;br /&gt;
 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.&lt;br /&gt;
 &lt;br /&gt;
 mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;mysql&amp;gt;  SELECT VERSION();&amp;lt;/code&amp;gt;&lt;br /&gt;
Sample Output:&lt;br /&gt;
&lt;br /&gt;
=== Create a User and Database: ===&lt;br /&gt;
To create a user and database in MariaDB/MySQL, use the commands below replacing where required:&lt;br /&gt;
 CREATE DATABASE sampledb;&lt;br /&gt;
 CREATE USER 'test_user'@'%' IDENTIFIED BY 'Passw0rd';&lt;br /&gt;
 GRANT ALL ON sampledb.* TO 'test_user'@'%' WITH GRANT OPTION;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
After this, you will have a database named '''sampledb''' and a user '''test_user''' who can be accessed remotely created as swell.&lt;br /&gt;
&lt;br /&gt;
Check the available databases:&lt;br /&gt;
 &amp;lt;mysql&amp;gt; SHOW databases;&lt;br /&gt;
 +--------------------+&lt;br /&gt;
 | Database           |&lt;br /&gt;
 +--------------------+&lt;br /&gt;
 | information_schema |&lt;br /&gt;
 | mysql              |&lt;br /&gt;
 | performance_schema |&lt;br /&gt;
 | sampledb           |&lt;br /&gt;
 | sys                |&lt;br /&gt;
 +--------------------+&lt;br /&gt;
 5 rows in set (0.00 sec)&lt;br /&gt;
 &lt;br /&gt;
 mysql&amp;gt; &lt;br /&gt;
View users:&lt;br /&gt;
 &amp;lt;mysql&amp;gt; SELECT User, Host FROM mysql.user;&lt;br /&gt;
 +------------------+-----------+&lt;br /&gt;
 | User             | Host      |&lt;br /&gt;
 +------------------+-----------+&lt;br /&gt;
 | test_user        | %         |&lt;br /&gt;
 | mysql.infoschema | localhost |&lt;br /&gt;
 | mysql.session    | localhost |&lt;br /&gt;
 | mysql.sys        | localhost |&lt;br /&gt;
 | root             | localhost |&lt;br /&gt;
 +------------------+-----------+&lt;br /&gt;
 5 rows in set (0.00 sec)&lt;br /&gt;
 &lt;br /&gt;
 mysql&amp;gt; &lt;br /&gt;
To delete a user, use the command with the below syntax:&lt;br /&gt;
 &amp;lt;code&amp;gt;DROP USER 'username'@'host';&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create Tables ===&lt;br /&gt;
We can then create and insert data into a table. For example in the created table above:&lt;br /&gt;
 USE sampledb;&lt;br /&gt;
 &lt;br /&gt;
 CREATE TABLE playground (&lt;br /&gt;
     equip_id serial PRIMARY KEY,&lt;br /&gt;
     type varchar (50) NOT NULL,&lt;br /&gt;
     color varchar (25) NOT NULL,&lt;br /&gt;
     location varchar(25) check (location in ('north', 'south', 'west', 'east', 'northeast', 'southeast', 'southwest', 'northwest')),&lt;br /&gt;
     install_date date&lt;br /&gt;
 );&lt;br /&gt;
Insert the data into the preferred table:&lt;br /&gt;
 INSERT INTO playground (type, color, location, install_date) VALUES ('slide', 'blue', 'south', '2017-04-28');&lt;br /&gt;
 INSERT INTO playground (type, color, location, install_date) VALUES ('swing', 'yellow', 'northwest', '2018-08-16');&lt;br /&gt;
View the added data:&lt;br /&gt;
 &amp;lt;mysql&amp;gt; SELECT * FROM playground;&lt;br /&gt;
 +----------+-------+--------+-----------+--------------+&lt;br /&gt;
 | equip_id | type  | color  | location  | install_date |&lt;br /&gt;
 +----------+-------+--------+-----------+--------------+&lt;br /&gt;
 |        1 | slide | blue   | south     | 2017-04-28   |&lt;br /&gt;
 |        2 | swing | yellow | northwest | 2018-08-16   |&lt;br /&gt;
 +----------+-------+--------+-----------+--------------+&lt;br /&gt;
 2 rows in set (0.00 sec)&lt;br /&gt;
 &lt;br /&gt;
 mysql&amp;gt; exit&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=MQTT&amp;diff=87</id>
		<title>MQTT</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=MQTT&amp;diff=87"/>
		<updated>2024-02-22T07:59:31Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Hoofdpagina|Menu]]  [[PhpMyAdmin]] [[Mariadb]] [[Node-red]]&lt;br /&gt;
&lt;br /&gt;
MQTT installeren&lt;br /&gt;
&lt;br /&gt;
# sudo apt-get install mosquitto&lt;br /&gt;
# sudo apt-get install mosquitto-clients&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Controleren of er berichten binnenkomen:&lt;br /&gt;
&lt;br /&gt;
mosquitto-sub -h 127.0.0.1 -u mqtt -P mqttpassword -v -t '#'   (optie:  | grep .........)&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=MQTT&amp;diff=86</id>
		<title>MQTT</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=MQTT&amp;diff=86"/>
		<updated>2024-02-22T07:59:09Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Hoofdpagina|Menu]]  [[PhpMyAdmin]] [[Mariadb]] [[Nodered]]&lt;br /&gt;
&lt;br /&gt;
MQTT installeren&lt;br /&gt;
&lt;br /&gt;
# sudo apt-get install mosquitto&lt;br /&gt;
# sudo apt-get install mosquitto-clients&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Controleren of er berichten binnenkomen:&lt;br /&gt;
&lt;br /&gt;
mosquitto-sub -h 127.0.0.1 -u mqtt -P mqttpassword -v -t '#'   (optie:  | grep .........)&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=85</id>
		<title>Node-red</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=85"/>
		<updated>2024-02-22T07:58:36Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Hoofdpagina|Menu]]  [[PhpMyAdmin]] [[Mariadb]] [[MQTT]]&lt;br /&gt;
&lt;br /&gt;
Node-Red&lt;br /&gt;
&lt;br /&gt;
Installatie Node-red.&lt;br /&gt;
&lt;br /&gt;
# Installatie&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bash &amp;lt;(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. aanpassen pasword.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once logged in,  a password hash needs to be generated by the Node-RED admin tool. A password hash is an encrypted representation of the chosen password. This prevents the storage of passwords as readable text.&lt;br /&gt;
&lt;br /&gt;
This admin tool is already installed on the Moduline controllers. The commands below can be used directly.&lt;br /&gt;
&lt;br /&gt;
Generate new pasword hash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red admin hash-pw&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, a new password can be chosen. After –''enter''– the hash is generated and is shown. Select the hash and copy it to the clipboard or local file on your computer.&lt;br /&gt;
&lt;br /&gt;
Now we’re going to open the Node-RED settings file where the password hash needs to be stored. The settingsfile is a .js file that can be opened and editted by nano (Linux CLI editor)&lt;br /&gt;
&lt;br /&gt;
Open the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano ~/.node-red/settings.js&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Scroll down (arrow down when using Putty) to ''adminAuth: {''  (see picture)&lt;br /&gt;
&lt;br /&gt;
Replace both hashes for ''password:'' and ''pass:'' with the hash created during former steps. Ensure that the hash is between the quotes!&lt;br /&gt;
&lt;br /&gt;
Note: If another username is required, ''username:'' and ''user:'' can also be changed here.&lt;br /&gt;
&lt;br /&gt;
Once the hashes are replaces with the new one, the file can be saved with:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Na installatie voeg ik de volgende modules toe:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red-contrib-config&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-modbus&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-knx-ultimate&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-buffer-parser&lt;br /&gt;
&lt;br /&gt;
node-red-dashboard&lt;br /&gt;
&lt;br /&gt;
node-red-node-mysql&lt;br /&gt;
&lt;br /&gt;
node-red-node-pushover&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deze kun je toevoegen via de manage-pallets in node-red.&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=84</id>
		<title>Node-red</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=84"/>
		<updated>2024-02-22T07:58:18Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Hoofdpagina|Menu]]  [[PhpMyAdmin]] [[Mariadb]] [[Mqtt]]&lt;br /&gt;
&lt;br /&gt;
Node-Red&lt;br /&gt;
&lt;br /&gt;
Installatie Node-red.&lt;br /&gt;
&lt;br /&gt;
# Installatie&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bash &amp;lt;(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. aanpassen pasword.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once logged in,  a password hash needs to be generated by the Node-RED admin tool. A password hash is an encrypted representation of the chosen password. This prevents the storage of passwords as readable text.&lt;br /&gt;
&lt;br /&gt;
This admin tool is already installed on the Moduline controllers. The commands below can be used directly.&lt;br /&gt;
&lt;br /&gt;
Generate new pasword hash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red admin hash-pw&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, a new password can be chosen. After –''enter''– the hash is generated and is shown. Select the hash and copy it to the clipboard or local file on your computer.&lt;br /&gt;
&lt;br /&gt;
Now we’re going to open the Node-RED settings file where the password hash needs to be stored. The settingsfile is a .js file that can be opened and editted by nano (Linux CLI editor)&lt;br /&gt;
&lt;br /&gt;
Open the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano ~/.node-red/settings.js&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Scroll down (arrow down when using Putty) to ''adminAuth: {''  (see picture)&lt;br /&gt;
&lt;br /&gt;
Replace both hashes for ''password:'' and ''pass:'' with the hash created during former steps. Ensure that the hash is between the quotes!&lt;br /&gt;
&lt;br /&gt;
Note: If another username is required, ''username:'' and ''user:'' can also be changed here.&lt;br /&gt;
&lt;br /&gt;
Once the hashes are replaces with the new one, the file can be saved with:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Na installatie voeg ik de volgende modules toe:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red-contrib-config&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-modbus&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-knx-ultimate&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-buffer-parser&lt;br /&gt;
&lt;br /&gt;
node-red-dashboard&lt;br /&gt;
&lt;br /&gt;
node-red-node-mysql&lt;br /&gt;
&lt;br /&gt;
node-red-node-pushover&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deze kun je toevoegen via de manage-pallets in node-red.&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=83</id>
		<title>Node-red</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=83"/>
		<updated>2024-02-22T07:58:00Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Hoofdpagina|Menu]]  [[PhpMyAdmin]] [[Mariadb] [Mqtt]]&lt;br /&gt;
&lt;br /&gt;
Node-Red&lt;br /&gt;
&lt;br /&gt;
Installatie Node-red.&lt;br /&gt;
&lt;br /&gt;
# Installatie&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bash &amp;lt;(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. aanpassen pasword.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once logged in,  a password hash needs to be generated by the Node-RED admin tool. A password hash is an encrypted representation of the chosen password. This prevents the storage of passwords as readable text.&lt;br /&gt;
&lt;br /&gt;
This admin tool is already installed on the Moduline controllers. The commands below can be used directly.&lt;br /&gt;
&lt;br /&gt;
Generate new pasword hash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red admin hash-pw&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, a new password can be chosen. After –''enter''– the hash is generated and is shown. Select the hash and copy it to the clipboard or local file on your computer.&lt;br /&gt;
&lt;br /&gt;
Now we’re going to open the Node-RED settings file where the password hash needs to be stored. The settingsfile is a .js file that can be opened and editted by nano (Linux CLI editor)&lt;br /&gt;
&lt;br /&gt;
Open the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano ~/.node-red/settings.js&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Scroll down (arrow down when using Putty) to ''adminAuth: {''  (see picture)&lt;br /&gt;
&lt;br /&gt;
Replace both hashes for ''password:'' and ''pass:'' with the hash created during former steps. Ensure that the hash is between the quotes!&lt;br /&gt;
&lt;br /&gt;
Note: If another username is required, ''username:'' and ''user:'' can also be changed here.&lt;br /&gt;
&lt;br /&gt;
Once the hashes are replaces with the new one, the file can be saved with:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Na installatie voeg ik de volgende modules toe:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red-contrib-config&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-modbus&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-knx-ultimate&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-buffer-parser&lt;br /&gt;
&lt;br /&gt;
node-red-dashboard&lt;br /&gt;
&lt;br /&gt;
node-red-node-mysql&lt;br /&gt;
&lt;br /&gt;
node-red-node-pushover&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deze kun je toevoegen via de manage-pallets in node-red.&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=82</id>
		<title>Node-red</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=82"/>
		<updated>2024-02-22T07:57:18Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Hoofdpagina|Menu]]  [[PhpMyAdmin]] [[Mariadb]]&lt;br /&gt;
&lt;br /&gt;
Node-Red&lt;br /&gt;
&lt;br /&gt;
Installatie Node-red.&lt;br /&gt;
&lt;br /&gt;
# Installatie&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bash &amp;lt;(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. aanpassen pasword.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once logged in,  a password hash needs to be generated by the Node-RED admin tool. A password hash is an encrypted representation of the chosen password. This prevents the storage of passwords as readable text.&lt;br /&gt;
&lt;br /&gt;
This admin tool is already installed on the Moduline controllers. The commands below can be used directly.&lt;br /&gt;
&lt;br /&gt;
Generate new pasword hash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red admin hash-pw&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, a new password can be chosen. After –''enter''– the hash is generated and is shown. Select the hash and copy it to the clipboard or local file on your computer.&lt;br /&gt;
&lt;br /&gt;
Now we’re going to open the Node-RED settings file where the password hash needs to be stored. The settingsfile is a .js file that can be opened and editted by nano (Linux CLI editor)&lt;br /&gt;
&lt;br /&gt;
Open the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano ~/.node-red/settings.js&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Scroll down (arrow down when using Putty) to ''adminAuth: {''  (see picture)&lt;br /&gt;
&lt;br /&gt;
Replace both hashes for ''password:'' and ''pass:'' with the hash created during former steps. Ensure that the hash is between the quotes!&lt;br /&gt;
&lt;br /&gt;
Note: If another username is required, ''username:'' and ''user:'' can also be changed here.&lt;br /&gt;
&lt;br /&gt;
Once the hashes are replaces with the new one, the file can be saved with:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Na installatie voeg ik de volgende modules toe:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red-contrib-config&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-modbus&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-knx-ultimate&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-buffer-parser&lt;br /&gt;
&lt;br /&gt;
node-red-dashboard&lt;br /&gt;
&lt;br /&gt;
node-red-node-mysql&lt;br /&gt;
&lt;br /&gt;
node-red-node-pushover&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deze kun je toevoegen via de manage-pallets in node-red.&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=81</id>
		<title>Node-red</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=81"/>
		<updated>2024-02-22T07:55:04Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Node-Red&lt;br /&gt;
&lt;br /&gt;
Installatie Node-red.&lt;br /&gt;
&lt;br /&gt;
# Installatie&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bash &amp;lt;(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. aanpassen pasword.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once logged in,  a password hash needs to be generated by the Node-RED admin tool. A password hash is an encrypted representation of the chosen password. This prevents the storage of passwords as readable text.&lt;br /&gt;
&lt;br /&gt;
This admin tool is already installed on the Moduline controllers. The commands below can be used directly.&lt;br /&gt;
&lt;br /&gt;
Generate new pasword hash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red admin hash-pw&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, a new password can be chosen. After –''enter''– the hash is generated and is shown. Select the hash and copy it to the clipboard or local file on your computer.&lt;br /&gt;
&lt;br /&gt;
Now we’re going to open the Node-RED settings file where the password hash needs to be stored. The settingsfile is a .js file that can be opened and editted by nano (Linux CLI editor)&lt;br /&gt;
&lt;br /&gt;
Open the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano ~/.node-red/settings.js&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Scroll down (arrow down when using Putty) to ''adminAuth: {''  (see picture)&lt;br /&gt;
&lt;br /&gt;
Replace both hashes for ''password:'' and ''pass:'' with the hash created during former steps. Ensure that the hash is between the quotes!&lt;br /&gt;
&lt;br /&gt;
Note: If another username is required, ''username:'' and ''user:'' can also be changed here.&lt;br /&gt;
&lt;br /&gt;
Once the hashes are replaces with the new one, the file can be saved with:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Na installatie voeg ik de volgende modules toe:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red-contrib-config&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-modbus&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-knx-ultimate&lt;br /&gt;
&lt;br /&gt;
node-red-contrib-buffer-parser&lt;br /&gt;
&lt;br /&gt;
node-red-dashboard&lt;br /&gt;
&lt;br /&gt;
node-red-node-mysql&lt;br /&gt;
&lt;br /&gt;
node-red-node-pushover&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deze kun je toevoegen via de manage-pallets in node-red.&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=80</id>
		<title>Node-red</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=80"/>
		<updated>2024-02-22T07:54:37Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Node-Red&lt;br /&gt;
&lt;br /&gt;
Installatie Node-red.&lt;br /&gt;
&lt;br /&gt;
# Installatie&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bash &amp;lt;(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. aanpassen pasword.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once logged in,  a password hash needs to be generated by the Node-RED admin tool. A password hash is an encrypted representation of the chosen password. This prevents the storage of passwords as readable text.&lt;br /&gt;
&lt;br /&gt;
This admin tool is already installed on the Moduline controllers. The commands below can be used directly.&lt;br /&gt;
&lt;br /&gt;
Generate new pasword hash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red admin hash-pw&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, a new password can be chosen. After –''enter''– the hash is generated and is shown. Select the hash and copy it to the clipboard or local file on your computer.&lt;br /&gt;
&lt;br /&gt;
Now we’re going to open the Node-RED settings file where the password hash needs to be stored. The settingsfile is a .js file that can be opened and editted by nano (Linux CLI editor)&lt;br /&gt;
&lt;br /&gt;
Open the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano ~/.node-red/settings.js&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Scroll down (arrow down when using Putty) to ''adminAuth: {''  (see picture)&lt;br /&gt;
&lt;br /&gt;
Replace both hashes for ''password:'' and ''pass:'' with the hash created during former steps. Ensure that the hash is between the quotes!&lt;br /&gt;
&lt;br /&gt;
Note: If another username is required, ''username:'' and ''user:'' can also be changed here.&lt;br /&gt;
&lt;br /&gt;
Once the hashes are replaces with the new one, the file can be saved with:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Na installatie voeg ik de volgende modules toe:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red-contrib-config&lt;br /&gt;
node-red-contrib-modbus&lt;br /&gt;
node-red-contrib-knx-ultimate&lt;br /&gt;
node-red-contrib-buffer-parser&lt;br /&gt;
node-red-dashboard&lt;br /&gt;
node-red-node-mysql&lt;br /&gt;
node-red-node-pushover&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deze kun je toevoegen via de manage-pallets in node-red.&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=79</id>
		<title>Wifi via commandline instellen</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=79"/>
		<updated>2024-02-22T07:50:21Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
Connect to Wi-Fi From Terminal on Debian 11/10 with WPA Supplicant&lt;br /&gt;
Last Updated: November 8th, 2022 Xiao Guoan (Admin) 20 Comments&lt;br /&gt;
Debian&lt;br /&gt;
&lt;br /&gt;
This tutorial is going to show you how to connect to Wi-Fi network from the command line on Debian 11/10 server and desktop using wpa_supplicant, which is an implementation of the supplicant component for the WPA protocol. A supplicant in wireless LAN is client software installed on end-user’s computer that needs to be authenticated in order to join a network.&lt;br /&gt;
&lt;br /&gt;
Please note that you will need to install the wpa_supplicant software before connecting to Wi-Fi, so you need to connect to Wired Ethernet first, which is done for just one time. If you don’t like this method, please don’t be mad at me. Maybe someday Debian will ship wpa_supplicant out of the box.&lt;br /&gt;
Step 1: Find The Name of Your Wireless Interface And Wireless Network&lt;br /&gt;
&lt;br /&gt;
Run iwconfig command to find the name of your wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
wlan0 is a common name for a wireless network interface on Linux systems. On systemd-based Linux distros, you might have a wireless interface named wlp4s0.&lt;br /&gt;
&lt;br /&gt;
debian server connect to wifi terminal&lt;br /&gt;
&lt;br /&gt;
As you can see, the wireless interface isn’t associated with any access point right now. Then run the following command to bring up the wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ip link set dev wlp4s0 up&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter the following error,&lt;br /&gt;
&lt;br /&gt;
RTNETLINK answers: Operation not possible due to RF-kill&lt;br /&gt;
&lt;br /&gt;
you need to unblock Wi-Fi with the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo rfkill unblock wifi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, find your wireless network name by scanning nearby networks with the command below. Replace wlp4s0 with your own wireless interface name. ESSID is the network name identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo iwlist wlp4s0 scan | grep ESSID&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian connect to wifi command line wpa supplicant&lt;br /&gt;
Step 2: Connect to Wi-Fi Network With WPA_Supplicant&lt;br /&gt;
&lt;br /&gt;
Now install wpa_supplicant on Debian 11/10 from the default software repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt install wpasupplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to create a file named wpa_supplicant.conf using the wpa_passphrase utility. wpa_supplicant.conf is the configuration file describing all networks that the user wants the computer to connect to. Run the following command to create this file. Replace ESSID (network name) and Wi-Fi passphrase with your own.&lt;br /&gt;
wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian wpa_passphrase&lt;br /&gt;
&lt;br /&gt;
If your ESSID contains whitespace such as (linuxbabe WiFi), you need to wrap the ESSID with double-quotes (&amp;quot;linuxbabe WiFi&amp;quot;) in the above command.&lt;br /&gt;
&lt;br /&gt;
The output of wpa_passphrase command will be piped to tee, and then written to the /etc/wpa_supplicant/wpa_supplicant.conf file. Now use the following command to connect your wireless card to the wireless access point.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output indicates your wireless card is successfully connected to an access point.&lt;br /&gt;
&lt;br /&gt;
Successfully initialized wpa_supplicant&lt;br /&gt;
wlp4s0: SME: Trying to authenticate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Trying to associate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Associated with c5:4a:21:53:ac:eb&lt;br /&gt;
wlp4s0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0&lt;br /&gt;
wlp4s0: WPA: Key negotiation completed with c5:4a:21:53:ac:eb [PTK=CCMP GTK=CCMP]&lt;br /&gt;
wlp4s0: CTRL-EVENT-CONNECTED - Connection to c5:4a:21:53:ac:eb completed [id=0 id_str=]&lt;br /&gt;
&lt;br /&gt;
Note that if you are using Debian desktop edition, then you need to stop Network Manager with the following command, otherwise it will cause a connection problem when using wpa_supplicant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl stop NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And disable NetworkManager auto-start at boot time by executing the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable NetworkManager-wait-online NetworkManager-dispatcher NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, wpa_supplicant runs in the foreground. If the connection is completed, then open up another terminal window and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see that the wireless interface is now associated with an access point.&lt;br /&gt;
&lt;br /&gt;
enable wifi on debian using terminal command&lt;br /&gt;
&lt;br /&gt;
You can press CTRL+C to stop the current wpa_supplicant process and run it in the background by adding the -B flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Although we’re authenticated and connected to a wireless network, we don’t have an IP address yet. To obtain a private IP address from DHCP server, use the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your wireless interface has a private IP address, which can be shown with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ip addr show wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian dhclient obtain private ip address&lt;br /&gt;
&lt;br /&gt;
Now you can access the Internet. To release the private IP address, run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0 -r&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Connecting to Hidden Wireless Network&lt;br /&gt;
&lt;br /&gt;
If your wireless router doesn’t broadcast ESSID, then you need to add the following line in /etc/wpa_supplicant/wpa_supplicant.conf file.&lt;br /&gt;
&lt;br /&gt;
scan_ssid=1&lt;br /&gt;
&lt;br /&gt;
Like below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;network={&lt;br /&gt;
        ssid=&amp;quot;LinuxBabe.Com Network&amp;quot;&lt;br /&gt;
        #psk=&amp;quot;12345qwert&amp;quot;&lt;br /&gt;
        psk=68add4c5fee7dc3d0dac810f89b805d6d147c01e281f07f475a3e0195&lt;br /&gt;
        scan_ssid=1&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step 3: Auto-Connect At System Boot Time&lt;br /&gt;
&lt;br /&gt;
To automatically connect to wireless network at boot time, we need to edit the wpa_supplicant.service file. It’s a good idea to copy the file from /lib/systemd/system/ directory to /etc/systemd/system/ directory, then edit the file content, because we don’t want a newer version of wpa_supplicant to override our modifications.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /lib/systemd/system/wpa_supplicant.service /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the file with a command-line text editor, such as Nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change it to the following. Here we added the configuration file and the wireless interface name to the ExecStart command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It’s recommended to always try to restart wpa_supplicant when failure is detected. Add the following right below the ExecStart line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Restart=always&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. (To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit, press Ctrl+X.) Then reload systemd.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl daemon-reload&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable wpa_supplicant service to start at boot time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also need to start dhclient at boot time to obtain a private IP address from DHCP server. This can be achieved by creating a systemd service unit for dhclient.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following text into the file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description= DHCP Client&lt;br /&gt;
Before=network.target&lt;br /&gt;
After=wpa_supplicant.service&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=forking&lt;br /&gt;
ExecStart=/sbin/dhclient wlp4s0 -v&lt;br /&gt;
ExecStop=/sbin/dhclient wlp4s0 -r&lt;br /&gt;
Restart=always&lt;br /&gt;
 &lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=multi-user.target&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. Then enable this service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to Obtain a Static IP Address&lt;br /&gt;
&lt;br /&gt;
If you want to obtain a static IP address, then you need to disable dhclient.service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a network config file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/network/static.network&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&lt;br /&gt;
[Network]&lt;br /&gt;
Address=192.168.1.8/24&lt;br /&gt;
Gateway=192.168.1.1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then create a .link file for the wireless interface.&lt;br /&gt;
&lt;br /&gt;
sudo nano /etc/systemd/network/10-wifi.link&lt;br /&gt;
&lt;br /&gt;
Add the following lines in this file. You need to use your own MAC address and wireless interface name. This is to prevent the system from changing the wireless interface name.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
MACAddress=a8:4b:05:2b:e8:54&lt;br /&gt;
&lt;br /&gt;
[Link]&lt;br /&gt;
NamePolicy=&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then disable the networking.service and enable systemd-networkd.service, which will take care of networking.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable networking&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now restart systemd-networkd to see if your configuration works.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl restart systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another way to obtain a static IP address is by logging into your router’s management interface and assigning a static IP to the MAC address of your wireless card, if your router supports this feature.&lt;br /&gt;
&lt;br /&gt;
Recommended Reading:&lt;br /&gt;
&lt;br /&gt;
    How to Use Systemd on Linux – Manage Services, Run Levels and Logs&lt;br /&gt;
&lt;br /&gt;
Multiple Wi-Fi Networks&lt;br /&gt;
&lt;br /&gt;
The /etc/wpa_supplicant.conf configuration file can include multiple Wi-Fi networks. wpa_supplicant automatically selects the best network based on the order of network blocks in the configuration file, network security level, and signal strength.&lt;br /&gt;
&lt;br /&gt;
To add a second Wi-Fi network, run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that you need to use the -a option with the tee command, which will append, instead of deleting the original content, the new Wifi-network to the file.&lt;br /&gt;
Wi-Fi Security&lt;br /&gt;
&lt;br /&gt;
Do not use WPA2 TKIP or WPA2 TKIP+AES as the encryption method in your Wi-Fi router. TKIP is not considered secure anymore. You can use WPA2-AES as the encryption method.&lt;br /&gt;
Wrapping Up&lt;br /&gt;
&lt;br /&gt;
I hope this tutorial helped you connect Debian 11/10 to Wi-Fi network from the command line with WPA Supplicant. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks 🙂&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Je kunt ook gebruik maken van de meegeleverde manager:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo raspi-config&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hiermee kun je de meeste wijzigen doorvoeren.&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=78</id>
		<title>Node-red</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Node-red&amp;diff=78"/>
		<updated>2024-02-22T07:28:23Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Node-Red&lt;br /&gt;
&lt;br /&gt;
Installatie Node-red.&lt;br /&gt;
&lt;br /&gt;
# Installatie&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bash &amp;lt;(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. aanpassen pasword.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once logged in,  a password hash needs to be generated by the Node-RED admin tool. A password hash is an encrypted representation of the chosen password. This prevents the storage of passwords as readable text.&lt;br /&gt;
&lt;br /&gt;
This admin tool is already installed on the Moduline controllers. The commands below can be used directly.&lt;br /&gt;
&lt;br /&gt;
Generate new pasword hash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;node-red admin hash-pw&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, a new password can be chosen. After –''enter''– the hash is generated and is shown. Select the hash and copy it to the clipboard or local file on your computer.&lt;br /&gt;
&lt;br /&gt;
Now we’re going to open the Node-RED settings file where the password hash needs to be stored. The settingsfile is a .js file that can be opened and editted by nano (Linux CLI editor)&lt;br /&gt;
&lt;br /&gt;
Open the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano ~/.node-red/settings.js&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Scroll down (arrow down when using Putty) to ''adminAuth: {''  (see picture)&lt;br /&gt;
&lt;br /&gt;
Replace both hashes for ''password:'' and ''pass:'' with the hash created during former steps. Ensure that the hash is between the quotes!&lt;br /&gt;
&lt;br /&gt;
Note: If another username is required, ''username:'' and ''user:'' can also be changed here.&lt;br /&gt;
&lt;br /&gt;
Once the hashes are replaces with the new one, the file can be saved with:&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=77</id>
		<title>Wifi via commandline instellen</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=77"/>
		<updated>2024-02-21T20:53:46Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
Connect to Wi-Fi From Terminal on Debian 11/10 with WPA Supplicant&lt;br /&gt;
Last Updated: November 8th, 2022 Xiao Guoan (Admin) 20 Comments&lt;br /&gt;
Debian&lt;br /&gt;
&lt;br /&gt;
This tutorial is going to show you how to connect to Wi-Fi network from the command line on Debian 11/10 server and desktop using wpa_supplicant, which is an implementation of the supplicant component for the WPA protocol. A supplicant in wireless LAN is client software installed on end-user’s computer that needs to be authenticated in order to join a network.&lt;br /&gt;
&lt;br /&gt;
Please note that you will need to install the wpa_supplicant software before connecting to Wi-Fi, so you need to connect to Wired Ethernet first, which is done for just one time. If you don’t like this method, please don’t be mad at me. Maybe someday Debian will ship wpa_supplicant out of the box.&lt;br /&gt;
Step 1: Find The Name of Your Wireless Interface And Wireless Network&lt;br /&gt;
&lt;br /&gt;
Run iwconfig command to find the name of your wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
wlan0 is a common name for a wireless network interface on Linux systems. On systemd-based Linux distros, you might have a wireless interface named wlp4s0.&lt;br /&gt;
&lt;br /&gt;
debian server connect to wifi terminal&lt;br /&gt;
&lt;br /&gt;
As you can see, the wireless interface isn’t associated with any access point right now. Then run the following command to bring up the wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ip link set dev wlp4s0 up&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter the following error,&lt;br /&gt;
&lt;br /&gt;
RTNETLINK answers: Operation not possible due to RF-kill&lt;br /&gt;
&lt;br /&gt;
you need to unblock Wi-Fi with the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo rfkill unblock wifi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, find your wireless network name by scanning nearby networks with the command below. Replace wlp4s0 with your own wireless interface name. ESSID is the network name identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo iwlist wlp4s0 scan | grep ESSID&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian connect to wifi command line wpa supplicant&lt;br /&gt;
Step 2: Connect to Wi-Fi Network With WPA_Supplicant&lt;br /&gt;
&lt;br /&gt;
Now install wpa_supplicant on Debian 11/10 from the default software repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt install wpasupplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to create a file named wpa_supplicant.conf using the wpa_passphrase utility. wpa_supplicant.conf is the configuration file describing all networks that the user wants the computer to connect to. Run the following command to create this file. Replace ESSID (network name) and Wi-Fi passphrase with your own.&lt;br /&gt;
wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian wpa_passphrase&lt;br /&gt;
&lt;br /&gt;
If your ESSID contains whitespace such as (linuxbabe WiFi), you need to wrap the ESSID with double-quotes (&amp;quot;linuxbabe WiFi&amp;quot;) in the above command.&lt;br /&gt;
&lt;br /&gt;
The output of wpa_passphrase command will be piped to tee, and then written to the /etc/wpa_supplicant/wpa_supplicant.conf file. Now use the following command to connect your wireless card to the wireless access point.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output indicates your wireless card is successfully connected to an access point.&lt;br /&gt;
&lt;br /&gt;
Successfully initialized wpa_supplicant&lt;br /&gt;
wlp4s0: SME: Trying to authenticate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Trying to associate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Associated with c5:4a:21:53:ac:eb&lt;br /&gt;
wlp4s0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0&lt;br /&gt;
wlp4s0: WPA: Key negotiation completed with c5:4a:21:53:ac:eb [PTK=CCMP GTK=CCMP]&lt;br /&gt;
wlp4s0: CTRL-EVENT-CONNECTED - Connection to c5:4a:21:53:ac:eb completed [id=0 id_str=]&lt;br /&gt;
&lt;br /&gt;
Note that if you are using Debian desktop edition, then you need to stop Network Manager with the following command, otherwise it will cause a connection problem when using wpa_supplicant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl stop NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And disable NetworkManager auto-start at boot time by executing the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable NetworkManager-wait-online NetworkManager-dispatcher NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, wpa_supplicant runs in the foreground. If the connection is completed, then open up another terminal window and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see that the wireless interface is now associated with an access point.&lt;br /&gt;
&lt;br /&gt;
enable wifi on debian using terminal command&lt;br /&gt;
&lt;br /&gt;
You can press CTRL+C to stop the current wpa_supplicant process and run it in the background by adding the -B flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Although we’re authenticated and connected to a wireless network, we don’t have an IP address yet. To obtain a private IP address from DHCP server, use the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your wireless interface has a private IP address, which can be shown with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ip addr show wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian dhclient obtain private ip address&lt;br /&gt;
&lt;br /&gt;
Now you can access the Internet. To release the private IP address, run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0 -r&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Connecting to Hidden Wireless Network&lt;br /&gt;
&lt;br /&gt;
If your wireless router doesn’t broadcast ESSID, then you need to add the following line in /etc/wpa_supplicant/wpa_supplicant.conf file.&lt;br /&gt;
&lt;br /&gt;
scan_ssid=1&lt;br /&gt;
&lt;br /&gt;
Like below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;network={&lt;br /&gt;
        ssid=&amp;quot;LinuxBabe.Com Network&amp;quot;&lt;br /&gt;
        #psk=&amp;quot;12345qwert&amp;quot;&lt;br /&gt;
        psk=68add4c5fee7dc3d0dac810f89b805d6d147c01e281f07f475a3e0195&lt;br /&gt;
        scan_ssid=1&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step 3: Auto-Connect At System Boot Time&lt;br /&gt;
&lt;br /&gt;
To automatically connect to wireless network at boot time, we need to edit the wpa_supplicant.service file. It’s a good idea to copy the file from /lib/systemd/system/ directory to /etc/systemd/system/ directory, then edit the file content, because we don’t want a newer version of wpa_supplicant to override our modifications.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /lib/systemd/system/wpa_supplicant.service /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the file with a command-line text editor, such as Nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change it to the following. Here we added the configuration file and the wireless interface name to the ExecStart command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It’s recommended to always try to restart wpa_supplicant when failure is detected. Add the following right below the ExecStart line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Restart=always&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. (To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit, press Ctrl+X.) Then reload systemd.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl daemon-reload&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable wpa_supplicant service to start at boot time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also need to start dhclient at boot time to obtain a private IP address from DHCP server. This can be achieved by creating a systemd service unit for dhclient.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following text into the file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description= DHCP Client&lt;br /&gt;
Before=network.target&lt;br /&gt;
After=wpa_supplicant.service&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=forking&lt;br /&gt;
ExecStart=/sbin/dhclient wlp4s0 -v&lt;br /&gt;
ExecStop=/sbin/dhclient wlp4s0 -r&lt;br /&gt;
Restart=always&lt;br /&gt;
 &lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=multi-user.target&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. Then enable this service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to Obtain a Static IP Address&lt;br /&gt;
&lt;br /&gt;
If you want to obtain a static IP address, then you need to disable dhclient.service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a network config file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/network/static.network&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&lt;br /&gt;
[Network]&lt;br /&gt;
Address=192.168.1.8/24&lt;br /&gt;
Gateway=192.168.1.1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then create a .link file for the wireless interface.&lt;br /&gt;
&lt;br /&gt;
sudo nano /etc/systemd/network/10-wifi.link&lt;br /&gt;
&lt;br /&gt;
Add the following lines in this file. You need to use your own MAC address and wireless interface name. This is to prevent the system from changing the wireless interface name.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
MACAddress=a8:4b:05:2b:e8:54&lt;br /&gt;
&lt;br /&gt;
[Link]&lt;br /&gt;
NamePolicy=&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then disable the networking.service and enable systemd-networkd.service, which will take care of networking.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable networking&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now restart systemd-networkd to see if your configuration works.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl restart systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another way to obtain a static IP address is by logging into your router’s management interface and assigning a static IP to the MAC address of your wireless card, if your router supports this feature.&lt;br /&gt;
&lt;br /&gt;
Recommended Reading:&lt;br /&gt;
&lt;br /&gt;
    How to Use Systemd on Linux – Manage Services, Run Levels and Logs&lt;br /&gt;
&lt;br /&gt;
Multiple Wi-Fi Networks&lt;br /&gt;
&lt;br /&gt;
The /etc/wpa_supplicant.conf configuration file can include multiple Wi-Fi networks. wpa_supplicant automatically selects the best network based on the order of network blocks in the configuration file, network security level, and signal strength.&lt;br /&gt;
&lt;br /&gt;
To add a second Wi-Fi network, run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that you need to use the -a option with the tee command, which will append, instead of deleting the original content, the new Wifi-network to the file.&lt;br /&gt;
Wi-Fi Security&lt;br /&gt;
&lt;br /&gt;
Do not use WPA2 TKIP or WPA2 TKIP+AES as the encryption method in your Wi-Fi router. TKIP is not considered secure anymore. You can use WPA2-AES as the encryption method.&lt;br /&gt;
Wrapping Up&lt;br /&gt;
&lt;br /&gt;
I hope this tutorial helped you connect Debian 11/10 to Wi-Fi network from the command line with WPA Supplicant. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks 🙂&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=76</id>
		<title>Wifi via commandline instellen</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=76"/>
		<updated>2024-02-21T20:53:29Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
Connect to Wi-Fi From Terminal on Debian 11/10 with WPA Supplicant&lt;br /&gt;
Last Updated: November 8th, 2022 Xiao Guoan (Admin) 20 Comments&lt;br /&gt;
Debian&lt;br /&gt;
&lt;br /&gt;
This tutorial is going to show you how to connect to Wi-Fi network from the command line on Debian 11/10 server and desktop using wpa_supplicant, which is an implementation of the supplicant component for the WPA protocol. A supplicant in wireless LAN is client software installed on end-user’s computer that needs to be authenticated in order to join a network.&lt;br /&gt;
&lt;br /&gt;
Please note that you will need to install the wpa_supplicant software before connecting to Wi-Fi, so you need to connect to Wired Ethernet first, which is done for just one time. If you don’t like this method, please don’t be mad at me. Maybe someday Debian will ship wpa_supplicant out of the box.&lt;br /&gt;
Step 1: Find The Name of Your Wireless Interface And Wireless Network&lt;br /&gt;
&lt;br /&gt;
Run iwconfig command to find the name of your wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
wlan0 is a common name for a wireless network interface on Linux systems. On systemd-based Linux distros, you might have a wireless interface named wlp4s0.&lt;br /&gt;
&lt;br /&gt;
debian server connect to wifi terminal&lt;br /&gt;
&lt;br /&gt;
As you can see, the wireless interface isn’t associated with any access point right now. Then run the following command to bring up the wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ip link set dev wlp4s0 up&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter the following error,&lt;br /&gt;
&lt;br /&gt;
RTNETLINK answers: Operation not possible due to RF-kill&lt;br /&gt;
&lt;br /&gt;
you need to unblock Wi-Fi with the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo rfkill unblock wifi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, find your wireless network name by scanning nearby networks with the command below. Replace wlp4s0 with your own wireless interface name. ESSID is the network name identifier.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;sudo iwlist wlp4s0 scan | grep ESSID&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian connect to wifi command line wpa supplicant&lt;br /&gt;
Step 2: Connect to Wi-Fi Network With WPA_Supplicant&lt;br /&gt;
&lt;br /&gt;
Now install wpa_supplicant on Debian 11/10 from the default software repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt install wpasupplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to create a file named wpa_supplicant.conf using the wpa_passphrase utility. wpa_supplicant.conf is the configuration file describing all networks that the user wants the computer to connect to. Run the following command to create this file. Replace ESSID (network name) and Wi-Fi passphrase with your own.&lt;br /&gt;
wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian wpa_passphrase&lt;br /&gt;
&lt;br /&gt;
If your ESSID contains whitespace such as (linuxbabe WiFi), you need to wrap the ESSID with double-quotes (&amp;quot;linuxbabe WiFi&amp;quot;) in the above command.&lt;br /&gt;
&lt;br /&gt;
The output of wpa_passphrase command will be piped to tee, and then written to the /etc/wpa_supplicant/wpa_supplicant.conf file. Now use the following command to connect your wireless card to the wireless access point.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output indicates your wireless card is successfully connected to an access point.&lt;br /&gt;
&lt;br /&gt;
Successfully initialized wpa_supplicant&lt;br /&gt;
wlp4s0: SME: Trying to authenticate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Trying to associate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Associated with c5:4a:21:53:ac:eb&lt;br /&gt;
wlp4s0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0&lt;br /&gt;
wlp4s0: WPA: Key negotiation completed with c5:4a:21:53:ac:eb [PTK=CCMP GTK=CCMP]&lt;br /&gt;
wlp4s0: CTRL-EVENT-CONNECTED - Connection to c5:4a:21:53:ac:eb completed [id=0 id_str=]&lt;br /&gt;
&lt;br /&gt;
Note that if you are using Debian desktop edition, then you need to stop Network Manager with the following command, otherwise it will cause a connection problem when using wpa_supplicant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl stop NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And disable NetworkManager auto-start at boot time by executing the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable NetworkManager-wait-online NetworkManager-dispatcher NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, wpa_supplicant runs in the foreground. If the connection is completed, then open up another terminal window and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see that the wireless interface is now associated with an access point.&lt;br /&gt;
&lt;br /&gt;
enable wifi on debian using terminal command&lt;br /&gt;
&lt;br /&gt;
You can press CTRL+C to stop the current wpa_supplicant process and run it in the background by adding the -B flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Although we’re authenticated and connected to a wireless network, we don’t have an IP address yet. To obtain a private IP address from DHCP server, use the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your wireless interface has a private IP address, which can be shown with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ip addr show wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian dhclient obtain private ip address&lt;br /&gt;
&lt;br /&gt;
Now you can access the Internet. To release the private IP address, run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0 -r&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Connecting to Hidden Wireless Network&lt;br /&gt;
&lt;br /&gt;
If your wireless router doesn’t broadcast ESSID, then you need to add the following line in /etc/wpa_supplicant/wpa_supplicant.conf file.&lt;br /&gt;
&lt;br /&gt;
scan_ssid=1&lt;br /&gt;
&lt;br /&gt;
Like below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;network={&lt;br /&gt;
        ssid=&amp;quot;LinuxBabe.Com Network&amp;quot;&lt;br /&gt;
        #psk=&amp;quot;12345qwert&amp;quot;&lt;br /&gt;
        psk=68add4c5fee7dc3d0dac810f89b805d6d147c01e281f07f475a3e0195&lt;br /&gt;
        scan_ssid=1&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step 3: Auto-Connect At System Boot Time&lt;br /&gt;
&lt;br /&gt;
To automatically connect to wireless network at boot time, we need to edit the wpa_supplicant.service file. It’s a good idea to copy the file from /lib/systemd/system/ directory to /etc/systemd/system/ directory, then edit the file content, because we don’t want a newer version of wpa_supplicant to override our modifications.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /lib/systemd/system/wpa_supplicant.service /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the file with a command-line text editor, such as Nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change it to the following. Here we added the configuration file and the wireless interface name to the ExecStart command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It’s recommended to always try to restart wpa_supplicant when failure is detected. Add the following right below the ExecStart line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Restart=always&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. (To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit, press Ctrl+X.) Then reload systemd.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl daemon-reload&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable wpa_supplicant service to start at boot time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also need to start dhclient at boot time to obtain a private IP address from DHCP server. This can be achieved by creating a systemd service unit for dhclient.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following text into the file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description= DHCP Client&lt;br /&gt;
Before=network.target&lt;br /&gt;
After=wpa_supplicant.service&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=forking&lt;br /&gt;
ExecStart=/sbin/dhclient wlp4s0 -v&lt;br /&gt;
ExecStop=/sbin/dhclient wlp4s0 -r&lt;br /&gt;
Restart=always&lt;br /&gt;
 &lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=multi-user.target&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. Then enable this service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to Obtain a Static IP Address&lt;br /&gt;
&lt;br /&gt;
If you want to obtain a static IP address, then you need to disable dhclient.service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a network config file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/network/static.network&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&lt;br /&gt;
[Network]&lt;br /&gt;
Address=192.168.1.8/24&lt;br /&gt;
Gateway=192.168.1.1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then create a .link file for the wireless interface.&lt;br /&gt;
&lt;br /&gt;
sudo nano /etc/systemd/network/10-wifi.link&lt;br /&gt;
&lt;br /&gt;
Add the following lines in this file. You need to use your own MAC address and wireless interface name. This is to prevent the system from changing the wireless interface name.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
MACAddress=a8:4b:05:2b:e8:54&lt;br /&gt;
&lt;br /&gt;
[Link]&lt;br /&gt;
NamePolicy=&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then disable the networking.service and enable systemd-networkd.service, which will take care of networking.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable networking&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now restart systemd-networkd to see if your configuration works.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl restart systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another way to obtain a static IP address is by logging into your router’s management interface and assigning a static IP to the MAC address of your wireless card, if your router supports this feature.&lt;br /&gt;
&lt;br /&gt;
Recommended Reading:&lt;br /&gt;
&lt;br /&gt;
    How to Use Systemd on Linux – Manage Services, Run Levels and Logs&lt;br /&gt;
&lt;br /&gt;
Multiple Wi-Fi Networks&lt;br /&gt;
&lt;br /&gt;
The /etc/wpa_supplicant.conf configuration file can include multiple Wi-Fi networks. wpa_supplicant automatically selects the best network based on the order of network blocks in the configuration file, network security level, and signal strength.&lt;br /&gt;
&lt;br /&gt;
To add a second Wi-Fi network, run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that you need to use the -a option with the tee command, which will append, instead of deleting the original content, the new Wifi-network to the file.&lt;br /&gt;
Wi-Fi Security&lt;br /&gt;
&lt;br /&gt;
Do not use WPA2 TKIP or WPA2 TKIP+AES as the encryption method in your Wi-Fi router. TKIP is not considered secure anymore. You can use WPA2-AES as the encryption method.&lt;br /&gt;
Wrapping Up&lt;br /&gt;
&lt;br /&gt;
I hope this tutorial helped you connect Debian 11/10 to Wi-Fi network from the command line with WPA Supplicant. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks 🙂&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=75</id>
		<title>Wifi via commandline instellen</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=75"/>
		<updated>2024-02-21T20:53:08Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
Connect to Wi-Fi From Terminal on Debian 11/10 with WPA Supplicant&lt;br /&gt;
Last Updated: November 8th, 2022 Xiao Guoan (Admin) 20 Comments&lt;br /&gt;
Debian&lt;br /&gt;
&lt;br /&gt;
This tutorial is going to show you how to connect to Wi-Fi network from the command line on Debian 11/10 server and desktop using wpa_supplicant, which is an implementation of the supplicant component for the WPA protocol. A supplicant in wireless LAN is client software installed on end-user’s computer that needs to be authenticated in order to join a network.&lt;br /&gt;
&lt;br /&gt;
Please note that you will need to install the wpa_supplicant software before connecting to Wi-Fi, so you need to connect to Wired Ethernet first, which is done for just one time. If you don’t like this method, please don’t be mad at me. Maybe someday Debian will ship wpa_supplicant out of the box.&lt;br /&gt;
Step 1: Find The Name of Your Wireless Interface And Wireless Network&lt;br /&gt;
&lt;br /&gt;
Run iwconfig command to find the name of your wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
wlan0 is a common name for a wireless network interface on Linux systems. On systemd-based Linux distros, you might have a wireless interface named wlp4s0.&lt;br /&gt;
&lt;br /&gt;
debian server connect to wifi terminal&lt;br /&gt;
&lt;br /&gt;
As you can see, the wireless interface isn’t associated with any access point right now. Then run the following command to bring up the wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ip link set dev wlp4s0 up&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter the following error,&lt;br /&gt;
&lt;br /&gt;
RTNETLINK answers: Operation not possible due to RF-kill&lt;br /&gt;
&lt;br /&gt;
you need to unblock Wi-Fi with the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo rfkill unblock wifi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, find your wireless network name by scanning nearby networks with the command below. Replace wlp4s0 with your own wireless interface name. ESSID is the network name identifier.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;sudo iwlist wlp4s0 scan | grep ESSID&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian connect to wifi command line wpa supplicant&lt;br /&gt;
Step 2: Connect to Wi-Fi Network With WPA_Supplicant&lt;br /&gt;
&lt;br /&gt;
Now install wpa_supplicant on Debian 11/10 from the default software repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt install wpasupplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to create a file named wpa_supplicant.conf using the wpa_passphrase utility. wpa_supplicant.conf is the configuration file describing all networks that the user wants the computer to connect to. Run the following command to create this file. Replace ESSID (network name) and Wi-Fi passphrase with your own.&lt;br /&gt;
wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian wpa_passphrase&lt;br /&gt;
&lt;br /&gt;
If your ESSID contains whitespace such as (linuxbabe WiFi), you need to wrap the ESSID with double-quotes (&amp;quot;linuxbabe WiFi&amp;quot;) in the above command.&lt;br /&gt;
&lt;br /&gt;
The output of wpa_passphrase command will be piped to tee, and then written to the /etc/wpa_supplicant/wpa_supplicant.conf file. Now use the following command to connect your wireless card to the wireless access point.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output indicates your wireless card is successfully connected to an access point.&lt;br /&gt;
&lt;br /&gt;
Successfully initialized wpa_supplicant&lt;br /&gt;
wlp4s0: SME: Trying to authenticate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Trying to associate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Associated with c5:4a:21:53:ac:eb&lt;br /&gt;
wlp4s0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0&lt;br /&gt;
wlp4s0: WPA: Key negotiation completed with c5:4a:21:53:ac:eb [PTK=CCMP GTK=CCMP]&lt;br /&gt;
wlp4s0: CTRL-EVENT-CONNECTED - Connection to c5:4a:21:53:ac:eb completed [id=0 id_str=]&lt;br /&gt;
&lt;br /&gt;
Note that if you are using Debian desktop edition, then you need to stop Network Manager with the following command, otherwise it will cause a connection problem when using wpa_supplicant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl stop NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And disable NetworkManager auto-start at boot time by executing the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable NetworkManager-wait-online NetworkManager-dispatcher NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, wpa_supplicant runs in the foreground. If the connection is completed, then open up another terminal window and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see that the wireless interface is now associated with an access point.&lt;br /&gt;
&lt;br /&gt;
enable wifi on debian using terminal command&lt;br /&gt;
&lt;br /&gt;
You can press CTRL+C to stop the current wpa_supplicant process and run it in the background by adding the -B flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;sudo wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Although we’re authenticated and connected to a wireless network, we don’t have an IP address yet. To obtain a private IP address from DHCP server, use the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your wireless interface has a private IP address, which can be shown with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ip addr show wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian dhclient obtain private ip address&lt;br /&gt;
&lt;br /&gt;
Now you can access the Internet. To release the private IP address, run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0 -r&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Connecting to Hidden Wireless Network&lt;br /&gt;
&lt;br /&gt;
If your wireless router doesn’t broadcast ESSID, then you need to add the following line in /etc/wpa_supplicant/wpa_supplicant.conf file.&lt;br /&gt;
&lt;br /&gt;
scan_ssid=1&lt;br /&gt;
&lt;br /&gt;
Like below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;network={&lt;br /&gt;
        ssid=&amp;quot;LinuxBabe.Com Network&amp;quot;&lt;br /&gt;
        #psk=&amp;quot;12345qwert&amp;quot;&lt;br /&gt;
        psk=68add4c5fee7dc3d0dac810f89b805d6d147c01e281f07f475a3e0195&lt;br /&gt;
        scan_ssid=1&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step 3: Auto-Connect At System Boot Time&lt;br /&gt;
&lt;br /&gt;
To automatically connect to wireless network at boot time, we need to edit the wpa_supplicant.service file. It’s a good idea to copy the file from /lib/systemd/system/ directory to /etc/systemd/system/ directory, then edit the file content, because we don’t want a newer version of wpa_supplicant to override our modifications.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /lib/systemd/system/wpa_supplicant.service /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the file with a command-line text editor, such as Nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change it to the following. Here we added the configuration file and the wireless interface name to the ExecStart command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It’s recommended to always try to restart wpa_supplicant when failure is detected. Add the following right below the ExecStart line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Restart=always&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. (To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit, press Ctrl+X.) Then reload systemd.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl daemon-reload&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable wpa_supplicant service to start at boot time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also need to start dhclient at boot time to obtain a private IP address from DHCP server. This can be achieved by creating a systemd service unit for dhclient.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following text into the file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description= DHCP Client&lt;br /&gt;
Before=network.target&lt;br /&gt;
After=wpa_supplicant.service&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=forking&lt;br /&gt;
ExecStart=/sbin/dhclient wlp4s0 -v&lt;br /&gt;
ExecStop=/sbin/dhclient wlp4s0 -r&lt;br /&gt;
Restart=always&lt;br /&gt;
 &lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=multi-user.target&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. Then enable this service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to Obtain a Static IP Address&lt;br /&gt;
&lt;br /&gt;
If you want to obtain a static IP address, then you need to disable dhclient.service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a network config file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/network/static.network&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&lt;br /&gt;
[Network]&lt;br /&gt;
Address=192.168.1.8/24&lt;br /&gt;
Gateway=192.168.1.1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then create a .link file for the wireless interface.&lt;br /&gt;
&lt;br /&gt;
sudo nano /etc/systemd/network/10-wifi.link&lt;br /&gt;
&lt;br /&gt;
Add the following lines in this file. You need to use your own MAC address and wireless interface name. This is to prevent the system from changing the wireless interface name.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
MACAddress=a8:4b:05:2b:e8:54&lt;br /&gt;
&lt;br /&gt;
[Link]&lt;br /&gt;
NamePolicy=&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then disable the networking.service and enable systemd-networkd.service, which will take care of networking.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable networking&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now restart systemd-networkd to see if your configuration works.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl restart systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another way to obtain a static IP address is by logging into your router’s management interface and assigning a static IP to the MAC address of your wireless card, if your router supports this feature.&lt;br /&gt;
&lt;br /&gt;
Recommended Reading:&lt;br /&gt;
&lt;br /&gt;
    How to Use Systemd on Linux – Manage Services, Run Levels and Logs&lt;br /&gt;
&lt;br /&gt;
Multiple Wi-Fi Networks&lt;br /&gt;
&lt;br /&gt;
The /etc/wpa_supplicant.conf configuration file can include multiple Wi-Fi networks. wpa_supplicant automatically selects the best network based on the order of network blocks in the configuration file, network security level, and signal strength.&lt;br /&gt;
&lt;br /&gt;
To add a second Wi-Fi network, run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that you need to use the -a option with the tee command, which will append, instead of deleting the original content, the new Wifi-network to the file.&lt;br /&gt;
Wi-Fi Security&lt;br /&gt;
&lt;br /&gt;
Do not use WPA2 TKIP or WPA2 TKIP+AES as the encryption method in your Wi-Fi router. TKIP is not considered secure anymore. You can use WPA2-AES as the encryption method.&lt;br /&gt;
Wrapping Up&lt;br /&gt;
&lt;br /&gt;
I hope this tutorial helped you connect Debian 11/10 to Wi-Fi network from the command line with WPA Supplicant. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks 🙂&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=74</id>
		<title>Wifi via commandline instellen</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=74"/>
		<updated>2024-02-21T20:52:30Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
Connect to Wi-Fi From Terminal on Debian 11/10 with WPA Supplicant&lt;br /&gt;
Last Updated: November 8th, 2022 Xiao Guoan (Admin) 20 Comments&lt;br /&gt;
Debian&lt;br /&gt;
&lt;br /&gt;
This tutorial is going to show you how to connect to Wi-Fi network from the command line on Debian 11/10 server and desktop using wpa_supplicant, which is an implementation of the supplicant component for the WPA protocol. A supplicant in wireless LAN is client software installed on end-user’s computer that needs to be authenticated in order to join a network.&lt;br /&gt;
&lt;br /&gt;
Please note that you will need to install the wpa_supplicant software before connecting to Wi-Fi, so you need to connect to Wired Ethernet first, which is done for just one time. If you don’t like this method, please don’t be mad at me. Maybe someday Debian will ship wpa_supplicant out of the box.&lt;br /&gt;
Step 1: Find The Name of Your Wireless Interface And Wireless Network&lt;br /&gt;
&lt;br /&gt;
Run iwconfig command to find the name of your wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
wlan0 is a common name for a wireless network interface on Linux systems. On systemd-based Linux distros, you might have a wireless interface named wlp4s0.&lt;br /&gt;
&lt;br /&gt;
debian server connect to wifi terminal&lt;br /&gt;
&lt;br /&gt;
As you can see, the wireless interface isn’t associated with any access point right now. Then run the following command to bring up the wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ip link set dev wlp4s0 up&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter the following error,&lt;br /&gt;
&lt;br /&gt;
RTNETLINK answers: Operation not possible due to RF-kill&lt;br /&gt;
&lt;br /&gt;
you need to unblock Wi-Fi with the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo rfkill unblock wifi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, find your wireless network name by scanning nearby networks with the command below. Replace wlp4s0 with your own wireless interface name. ESSID is the network name identifier.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;sudo iwlist wlp4s0 scan | grep ESSID&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian connect to wifi command line wpa supplicant&lt;br /&gt;
Step 2: Connect to Wi-Fi Network With WPA_Supplicant&lt;br /&gt;
&lt;br /&gt;
Now install wpa_supplicant on Debian 11/10 from the default software repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt install wpasupplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to create a file named wpa_supplicant.conf using the wpa_passphrase utility. wpa_supplicant.conf is the configuration file describing all networks that the user wants the computer to connect to. Run the following command to create this file. Replace ESSID (network name) and Wi-Fi passphrase with your own.&lt;br /&gt;
wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian wpa_passphrase&lt;br /&gt;
&lt;br /&gt;
If your ESSID contains whitespace such as (linuxbabe WiFi), you need to wrap the ESSID with double-quotes (&amp;quot;linuxbabe WiFi&amp;quot;) in the above command.&lt;br /&gt;
&lt;br /&gt;
The output of wpa_passphrase command will be piped to tee, and then written to the /etc/wpa_supplicant/wpa_supplicant.conf file. Now use the following command to connect your wireless card to the wireless access point.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output indicates your wireless card is successfully connected to an access point.&lt;br /&gt;
&lt;br /&gt;
Successfully initialized wpa_supplicant&lt;br /&gt;
wlp4s0: SME: Trying to authenticate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Trying to associate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Associated with c5:4a:21:53:ac:eb&lt;br /&gt;
wlp4s0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0&lt;br /&gt;
wlp4s0: WPA: Key negotiation completed with c5:4a:21:53:ac:eb [PTK=CCMP GTK=CCMP]&lt;br /&gt;
wlp4s0: CTRL-EVENT-CONNECTED - Connection to c5:4a:21:53:ac:eb completed [id=0 id_str=]&lt;br /&gt;
&lt;br /&gt;
Note that if you are using Debian desktop edition, then you need to stop Network Manager with the following command, otherwise it will cause a connection problem when using wpa_supplicant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl stop NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And disable NetworkManager auto-start at boot time by executing the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable NetworkManager-wait-online NetworkManager-dispatcher NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, wpa_supplicant runs in the foreground. If the connection is completed, then open up another terminal window and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see that the wireless interface is now associated with an access point.&lt;br /&gt;
&lt;br /&gt;
enable wifi on debian using terminal command&lt;br /&gt;
&lt;br /&gt;
You can press CTRL+C to stop the current wpa_supplicant process and run it in the background by adding the -B flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;sudo wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Although we’re authenticated and connected to a wireless network, we don’t have an IP address yet. To obtain a private IP address from DHCP server, use the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your wireless interface has a private IP address, which can be shown with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ip addr show wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian dhclient obtain private ip address&lt;br /&gt;
&lt;br /&gt;
Now you can access the Internet. To release the private IP address, run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0 -r&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Connecting to Hidden Wireless Network&lt;br /&gt;
&lt;br /&gt;
If your wireless router doesn’t broadcast ESSID, then you need to add the following line in /etc/wpa_supplicant/wpa_supplicant.conf file.&lt;br /&gt;
&lt;br /&gt;
scan_ssid=1&lt;br /&gt;
&lt;br /&gt;
Like below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;network=&amp;lt;nowiki&amp;gt;{&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
        ssid=&amp;quot;LinuxBabe.Com Network&amp;quot;&lt;br /&gt;
        #psk=&amp;quot;12345qwert&amp;quot;&lt;br /&gt;
        psk=68add4c5fee7dc3d0dac810f89b805d6d147c01e281f07f475a3e0195&lt;br /&gt;
        scan_ssid=1&lt;br /&gt;
&amp;lt;nowiki&amp;gt;}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step 3: Auto-Connect At System Boot Time&lt;br /&gt;
&lt;br /&gt;
To automatically connect to wireless network at boot time, we need to edit the wpa_supplicant.service file. It’s a good idea to copy the file from /lib/systemd/system/ directory to /etc/systemd/system/ directory, then edit the file content, because we don’t want a newer version of wpa_supplicant to override our modifications.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /lib/systemd/system/wpa_supplicant.service /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the file with a command-line text editor, such as Nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change it to the following. Here we added the configuration file and the wireless interface name to the ExecStart command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It’s recommended to always try to restart wpa_supplicant when failure is detected. Add the following right below the ExecStart line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Restart=always&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. (To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit, press Ctrl+X.) Then reload systemd.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl daemon-reload&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable wpa_supplicant service to start at boot time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also need to start dhclient at boot time to obtain a private IP address from DHCP server. This can be achieved by creating a systemd service unit for dhclient.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following text into the file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description= DHCP Client&lt;br /&gt;
Before=network.target&lt;br /&gt;
After=wpa_supplicant.service&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=forking&lt;br /&gt;
ExecStart=/sbin/dhclient wlp4s0 -v&lt;br /&gt;
ExecStop=/sbin/dhclient wlp4s0 -r&lt;br /&gt;
Restart=always&lt;br /&gt;
 &lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=multi-user.target&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. Then enable this service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to Obtain a Static IP Address&lt;br /&gt;
&lt;br /&gt;
If you want to obtain a static IP address, then you need to disable dhclient.service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a network config file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/network/static.network&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&lt;br /&gt;
[Network]&lt;br /&gt;
Address=192.168.1.8/24&lt;br /&gt;
Gateway=192.168.1.1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then create a .link file for the wireless interface.&lt;br /&gt;
&lt;br /&gt;
sudo nano /etc/systemd/network/10-wifi.link&lt;br /&gt;
&lt;br /&gt;
Add the following lines in this file. You need to use your own MAC address and wireless interface name. This is to prevent the system from changing the wireless interface name.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
MACAddress=a8:4b:05:2b:e8:54&lt;br /&gt;
&lt;br /&gt;
[Link]&lt;br /&gt;
NamePolicy=&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then disable the networking.service and enable systemd-networkd.service, which will take care of networking.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable networking&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now restart systemd-networkd to see if your configuration works.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl restart systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another way to obtain a static IP address is by logging into your router’s management interface and assigning a static IP to the MAC address of your wireless card, if your router supports this feature.&lt;br /&gt;
&lt;br /&gt;
Recommended Reading:&lt;br /&gt;
&lt;br /&gt;
    How to Use Systemd on Linux – Manage Services, Run Levels and Logs&lt;br /&gt;
&lt;br /&gt;
Multiple Wi-Fi Networks&lt;br /&gt;
&lt;br /&gt;
The /etc/wpa_supplicant.conf configuration file can include multiple Wi-Fi networks. wpa_supplicant automatically selects the best network based on the order of network blocks in the configuration file, network security level, and signal strength.&lt;br /&gt;
&lt;br /&gt;
To add a second Wi-Fi network, run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that you need to use the -a option with the tee command, which will append, instead of deleting the original content, the new Wifi-network to the file.&lt;br /&gt;
Wi-Fi Security&lt;br /&gt;
&lt;br /&gt;
Do not use WPA2 TKIP or WPA2 TKIP+AES as the encryption method in your Wi-Fi router. TKIP is not considered secure anymore. You can use WPA2-AES as the encryption method.&lt;br /&gt;
Wrapping Up&lt;br /&gt;
&lt;br /&gt;
I hope this tutorial helped you connect Debian 11/10 to Wi-Fi network from the command line with WPA Supplicant. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks 🙂&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=73</id>
		<title>Wifi via commandline instellen</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=73"/>
		<updated>2024-02-21T20:50:26Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
Connect to Wi-Fi From Terminal on Debian 11/10 with WPA Supplicant&lt;br /&gt;
Last Updated: November 8th, 2022 Xiao Guoan (Admin) 20 Comments&lt;br /&gt;
Debian&lt;br /&gt;
&lt;br /&gt;
This tutorial is going to show you how to connect to Wi-Fi network from the command line on Debian 11/10 server and desktop using wpa_supplicant, which is an implementation of the supplicant component for the WPA protocol. A supplicant in wireless LAN is client software installed on end-user’s computer that needs to be authenticated in order to join a network.&lt;br /&gt;
&lt;br /&gt;
Please note that you will need to install the wpa_supplicant software before connecting to Wi-Fi, so you need to connect to Wired Ethernet first, which is done for just one time. If you don’t like this method, please don’t be mad at me. Maybe someday Debian will ship wpa_supplicant out of the box.&lt;br /&gt;
Step 1: Find The Name of Your Wireless Interface And Wireless Network&lt;br /&gt;
&lt;br /&gt;
Run iwconfig command to find the name of your wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
wlan0 is a common name for a wireless network interface on Linux systems. On systemd-based Linux distros, you might have a wireless interface named wlp4s0.&lt;br /&gt;
&lt;br /&gt;
debian server connect to wifi terminal&lt;br /&gt;
&lt;br /&gt;
As you can see, the wireless interface isn’t associated with any access point right now. Then run the following command to bring up the wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ip link set dev wlp4s0 up&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter the following error,&lt;br /&gt;
&lt;br /&gt;
RTNETLINK answers: Operation not possible due to RF-kill&lt;br /&gt;
&lt;br /&gt;
you need to unblock Wi-Fi with the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo rfkill unblock wifi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, find your wireless network name by scanning nearby networks with the command below. Replace wlp4s0 with your own wireless interface name. ESSID is the network name identifier.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;sudo iwlist wlp4s0 scan | grep ESSID&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian connect to wifi command line wpa supplicant&lt;br /&gt;
Step 2: Connect to Wi-Fi Network With WPA_Supplicant&lt;br /&gt;
&lt;br /&gt;
Now install wpa_supplicant on Debian 11/10 from the default software repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt install wpasupplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to create a file named wpa_supplicant.conf using the wpa_passphrase utility. wpa_supplicant.conf is the configuration file describing all networks that the user wants the computer to connect to. Run the following command to create this file. Replace ESSID (network name) and Wi-Fi passphrase with your own.&lt;br /&gt;
wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian wpa_passphrase&lt;br /&gt;
&lt;br /&gt;
If your ESSID contains whitespace such as (linuxbabe WiFi), you need to wrap the ESSID with double-quotes (&amp;quot;linuxbabe WiFi&amp;quot;) in the above command.&lt;br /&gt;
&lt;br /&gt;
The output of wpa_passphrase command will be piped to tee, and then written to the /etc/wpa_supplicant/wpa_supplicant.conf file. Now use the following command to connect your wireless card to the wireless access point.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output indicates your wireless card is successfully connected to an access point.&lt;br /&gt;
&lt;br /&gt;
Successfully initialized wpa_supplicant&lt;br /&gt;
wlp4s0: SME: Trying to authenticate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Trying to associate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Associated with c5:4a:21:53:ac:eb&lt;br /&gt;
wlp4s0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0&lt;br /&gt;
wlp4s0: WPA: Key negotiation completed with c5:4a:21:53:ac:eb [PTK=CCMP GTK=CCMP]&lt;br /&gt;
wlp4s0: CTRL-EVENT-CONNECTED - Connection to c5:4a:21:53:ac:eb completed [id=0 id_str=]&lt;br /&gt;
&lt;br /&gt;
Note that if you are using Debian desktop edition, then you need to stop Network Manager with the following command, otherwise it will cause a connection problem when using wpa_supplicant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl stop NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And disable NetworkManager auto-start at boot time by executing the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable NetworkManager-wait-online NetworkManager-dispatcher NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, wpa_supplicant runs in the foreground. If the connection is completed, then open up another terminal window and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see that the wireless interface is now associated with an access point.&lt;br /&gt;
&lt;br /&gt;
enable wifi on debian using terminal command&lt;br /&gt;
&lt;br /&gt;
You can press CTRL+C to stop the current wpa_supplicant process and run it in the background by adding the -B flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;sudo wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Although we’re authenticated and connected to a wireless network, we don’t have an IP address yet. To obtain a private IP address from DHCP server, use the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your wireless interface has a private IP address, which can be shown with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ip addr show wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian dhclient obtain private ip address&lt;br /&gt;
&lt;br /&gt;
Now you can access the Internet. To release the private IP address, run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0 -r&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Connecting to Hidden Wireless Network&lt;br /&gt;
&lt;br /&gt;
If your wireless router doesn’t broadcast ESSID, then you need to add the following line in /etc/wpa_supplicant/wpa_supplicant.conf file.&lt;br /&gt;
&lt;br /&gt;
scan_ssid=1&lt;br /&gt;
&lt;br /&gt;
Like below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;network&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;{&lt;br /&gt;
        ssid=&amp;quot;LinuxBabe.Com Network&amp;quot;&lt;br /&gt;
        #psk=&amp;quot;12345qwert&amp;quot;&lt;br /&gt;
        psk=68add4c5fee7dc3d0dac810f89b805d6d147c01e281f07f475a3e0195&lt;br /&gt;
        scan_ssid=1&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step 3: Auto-Connect At System Boot Time&lt;br /&gt;
&lt;br /&gt;
To automatically connect to wireless network at boot time, we need to edit the wpa_supplicant.service file. It’s a good idea to copy the file from /lib/systemd/system/ directory to /etc/systemd/system/ directory, then edit the file content, because we don’t want a newer version of wpa_supplicant to override our modifications.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /lib/systemd/system/wpa_supplicant.service /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the file with a command-line text editor, such as Nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change it to the following. Here we added the configuration file and the wireless interface name to the ExecStart command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It’s recommended to always try to restart wpa_supplicant when failure is detected. Add the following right below the ExecStart line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Restart=always&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. (To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit, press Ctrl+X.) Then reload systemd.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl daemon-reload&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable wpa_supplicant service to start at boot time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also need to start dhclient at boot time to obtain a private IP address from DHCP server. This can be achieved by creating a systemd service unit for dhclient.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following text into the file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description= DHCP Client&lt;br /&gt;
Before=network.target&lt;br /&gt;
After=wpa_supplicant.service&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=forking&lt;br /&gt;
ExecStart=/sbin/dhclient wlp4s0 -v&lt;br /&gt;
ExecStop=/sbin/dhclient wlp4s0 -r&lt;br /&gt;
Restart=always&lt;br /&gt;
 &lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=multi-user.target&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. Then enable this service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to Obtain a Static IP Address&lt;br /&gt;
&lt;br /&gt;
If you want to obtain a static IP address, then you need to disable dhclient.service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a network config file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/network/static.network&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&lt;br /&gt;
[Network]&lt;br /&gt;
Address=192.168.1.8/24&lt;br /&gt;
Gateway=192.168.1.1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then create a .link file for the wireless interface.&lt;br /&gt;
&lt;br /&gt;
sudo nano /etc/systemd/network/10-wifi.link&lt;br /&gt;
&lt;br /&gt;
Add the following lines in this file. You need to use your own MAC address and wireless interface name. This is to prevent the system from changing the wireless interface name.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
MACAddress=a8:4b:05:2b:e8:54&lt;br /&gt;
&lt;br /&gt;
[Link]&lt;br /&gt;
NamePolicy=&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then disable the networking.service and enable systemd-networkd.service, which will take care of networking.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable networking&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now restart systemd-networkd to see if your configuration works.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl restart systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another way to obtain a static IP address is by logging into your router’s management interface and assigning a static IP to the MAC address of your wireless card, if your router supports this feature.&lt;br /&gt;
&lt;br /&gt;
Recommended Reading:&lt;br /&gt;
&lt;br /&gt;
    How to Use Systemd on Linux – Manage Services, Run Levels and Logs&lt;br /&gt;
&lt;br /&gt;
Multiple Wi-Fi Networks&lt;br /&gt;
&lt;br /&gt;
The /etc/wpa_supplicant.conf configuration file can include multiple Wi-Fi networks. wpa_supplicant automatically selects the best network based on the order of network blocks in the configuration file, network security level, and signal strength.&lt;br /&gt;
&lt;br /&gt;
To add a second Wi-Fi network, run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that you need to use the -a option with the tee command, which will append, instead of deleting the original content, the new Wifi-network to the file.&lt;br /&gt;
Wi-Fi Security&lt;br /&gt;
&lt;br /&gt;
Do not use WPA2 TKIP or WPA2 TKIP+AES as the encryption method in your Wi-Fi router. TKIP is not considered secure anymore. You can use WPA2-AES as the encryption method.&lt;br /&gt;
Wrapping Up&lt;br /&gt;
&lt;br /&gt;
I hope this tutorial helped you connect Debian 11/10 to Wi-Fi network from the command line with WPA Supplicant. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks 🙂&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
	<entry>
		<id>https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=72</id>
		<title>Wifi via commandline instellen</title>
		<link rel="alternate" type="text/html" href="https://thuis.kwantwebdesign.nl/index.php?title=Wifi_via_commandline_instellen&amp;diff=72"/>
		<updated>2024-02-21T20:49:30Z</updated>

		<summary type="html">&lt;p&gt;Erwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
Connect to Wi-Fi From Terminal on Debian 11/10 with WPA Supplicant&lt;br /&gt;
Last Updated: November 8th, 2022 Xiao Guoan (Admin) 20 Comments&lt;br /&gt;
Debian&lt;br /&gt;
&lt;br /&gt;
This tutorial is going to show you how to connect to Wi-Fi network from the command line on Debian 11/10 server and desktop using wpa_supplicant, which is an implementation of the supplicant component for the WPA protocol. A supplicant in wireless LAN is client software installed on end-user’s computer that needs to be authenticated in order to join a network.&lt;br /&gt;
&lt;br /&gt;
Please note that you will need to install the wpa_supplicant software before connecting to Wi-Fi, so you need to connect to Wired Ethernet first, which is done for just one time. If you don’t like this method, please don’t be mad at me. Maybe someday Debian will ship wpa_supplicant out of the box.&lt;br /&gt;
Step 1: Find The Name of Your Wireless Interface And Wireless Network&lt;br /&gt;
&lt;br /&gt;
Run iwconfig command to find the name of your wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
wlan0 is a common name for a wireless network interface on Linux systems. On systemd-based Linux distros, you might have a wireless interface named wlp4s0.&lt;br /&gt;
&lt;br /&gt;
debian server connect to wifi terminal&lt;br /&gt;
&lt;br /&gt;
As you can see, the wireless interface isn’t associated with any access point right now. Then run the following command to bring up the wireless interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ip link set dev wlp4s0 up&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter the following error,&lt;br /&gt;
&lt;br /&gt;
RTNETLINK answers: Operation not possible due to RF-kill&lt;br /&gt;
&lt;br /&gt;
you need to unblock Wi-Fi with the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo rfkill unblock wifi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, find your wireless network name by scanning nearby networks with the command below. Replace wlp4s0 with your own wireless interface name. ESSID is the network name identifier.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;sudo iwlist wlp4s0 scan | grep ESSID&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian connect to wifi command line wpa supplicant&lt;br /&gt;
Step 2: Connect to Wi-Fi Network With WPA_Supplicant&lt;br /&gt;
&lt;br /&gt;
Now install wpa_supplicant on Debian 11/10 from the default software repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt install wpasupplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to create a file named wpa_supplicant.conf using the wpa_passphrase utility. wpa_supplicant.conf is the configuration file describing all networks that the user wants the computer to connect to. Run the following command to create this file. Replace ESSID (network name) and Wi-Fi passphrase with your own.&lt;br /&gt;
wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian wpa_passphrase&lt;br /&gt;
&lt;br /&gt;
If your ESSID contains whitespace such as (linuxbabe WiFi), you need to wrap the ESSID with double-quotes (&amp;quot;linuxbabe WiFi&amp;quot;) in the above command.&lt;br /&gt;
&lt;br /&gt;
The output of wpa_passphrase command will be piped to tee, and then written to the /etc/wpa_supplicant/wpa_supplicant.conf file. Now use the following command to connect your wireless card to the wireless access point.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output indicates your wireless card is successfully connected to an access point.&lt;br /&gt;
&lt;br /&gt;
Successfully initialized wpa_supplicant&lt;br /&gt;
wlp4s0: SME: Trying to authenticate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Trying to associate with c5:4a:21:53:ac:eb (SSID='CMCC-11802' freq=2437 MHz)&lt;br /&gt;
wlp4s0: Associated with c5:4a:21:53:ac:eb&lt;br /&gt;
wlp4s0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0&lt;br /&gt;
wlp4s0: WPA: Key negotiation completed with c5:4a:21:53:ac:eb [PTK=CCMP GTK=CCMP]&lt;br /&gt;
wlp4s0: CTRL-EVENT-CONNECTED - Connection to c5:4a:21:53:ac:eb completed [id=0 id_str=]&lt;br /&gt;
&lt;br /&gt;
Note that if you are using Debian desktop edition, then you need to stop Network Manager with the following command, otherwise it will cause a connection problem when using wpa_supplicant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl stop NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And disable NetworkManager auto-start at boot time by executing the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable NetworkManager-wait-online NetworkManager-dispatcher NetworkManager&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, wpa_supplicant runs in the foreground. If the connection is completed, then open up another terminal window and run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iwconfig&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see that the wireless interface is now associated with an access point.&lt;br /&gt;
&lt;br /&gt;
enable wifi on debian using terminal command&lt;br /&gt;
&lt;br /&gt;
You can press CTRL+C to stop the current wpa_supplicant process and run it in the background by adding the -B flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;sudo wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Although we’re authenticated and connected to a wireless network, we don’t have an IP address yet. To obtain a private IP address from DHCP server, use the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your wireless interface has a private IP address, which can be shown with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ip addr show wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
debian dhclient obtain private ip address&lt;br /&gt;
&lt;br /&gt;
Now you can access the Internet. To release the private IP address, run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo dhclient wlp4s0 -r&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Connecting to Hidden Wireless Network&lt;br /&gt;
&lt;br /&gt;
If your wireless router doesn’t broadcast ESSID, then you need to add the following line in /etc/wpa_supplicant/wpa_supplicant.conf file.&lt;br /&gt;
&lt;br /&gt;
scan_ssid=1&lt;br /&gt;
&lt;br /&gt;
Like below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&amp;lt;code&amp;gt;network={&lt;br /&gt;
        ssid=&amp;quot;LinuxBabe.Com Network&amp;quot;&lt;br /&gt;
        #psk=&amp;quot;12345qwert&amp;quot;&lt;br /&gt;
        psk=68add4c5fee7dc3d0dac810f89b805d6d147c01e281f07f475a3e0195&lt;br /&gt;
        scan_ssid=1&lt;br /&gt;
}&amp;lt;/code&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step 3: Auto-Connect At System Boot Time&lt;br /&gt;
&lt;br /&gt;
To automatically connect to wireless network at boot time, we need to edit the wpa_supplicant.service file. It’s a good idea to copy the file from /lib/systemd/system/ directory to /etc/systemd/system/ directory, then edit the file content, because we don’t want a newer version of wpa_supplicant to override our modifications.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /lib/systemd/system/wpa_supplicant.service /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the file with a command-line text editor, such as Nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change it to the following. Here we added the configuration file and the wireless interface name to the ExecStart command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ExecStart=/sbin/wpa_supplicant -u -s -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It’s recommended to always try to restart wpa_supplicant when failure is detected. Add the following right below the ExecStart line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Restart=always&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. (To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit, press Ctrl+X.) Then reload systemd.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl daemon-reload&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable wpa_supplicant service to start at boot time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable wpa_supplicant.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also need to start dhclient at boot time to obtain a private IP address from DHCP server. This can be achieved by creating a systemd service unit for dhclient.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/system/dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following text into the file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description= DHCP Client&lt;br /&gt;
Before=network.target&lt;br /&gt;
After=wpa_supplicant.service&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=forking&lt;br /&gt;
ExecStart=/sbin/dhclient wlp4s0 -v&lt;br /&gt;
ExecStop=/sbin/dhclient wlp4s0 -r&lt;br /&gt;
Restart=always&lt;br /&gt;
 &lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=multi-user.target&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and close the file. Then enable this service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl enable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to Obtain a Static IP Address&lt;br /&gt;
&lt;br /&gt;
If you want to obtain a static IP address, then you need to disable dhclient.service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable dhclient.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a network config file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/systemd/network/static.network&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&lt;br /&gt;
[Network]&lt;br /&gt;
Address=192.168.1.8/24&lt;br /&gt;
Gateway=192.168.1.1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then create a .link file for the wireless interface.&lt;br /&gt;
&lt;br /&gt;
sudo nano /etc/systemd/network/10-wifi.link&lt;br /&gt;
&lt;br /&gt;
Add the following lines in this file. You need to use your own MAC address and wireless interface name. This is to prevent the system from changing the wireless interface name.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[Match]&lt;br /&gt;
MACAddress=a8:4b:05:2b:e8:54&lt;br /&gt;
&lt;br /&gt;
[Link]&lt;br /&gt;
NamePolicy=&lt;br /&gt;
Name=wlp4s0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Save and close the file. Then disable the networking.service and enable systemd-networkd.service, which will take care of networking.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl disable networking&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now restart systemd-networkd to see if your configuration works.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo systemctl restart systemd-networkd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another way to obtain a static IP address is by logging into your router’s management interface and assigning a static IP to the MAC address of your wireless card, if your router supports this feature.&lt;br /&gt;
&lt;br /&gt;
Recommended Reading:&lt;br /&gt;
&lt;br /&gt;
    How to Use Systemd on Linux – Manage Services, Run Levels and Logs&lt;br /&gt;
&lt;br /&gt;
Multiple Wi-Fi Networks&lt;br /&gt;
&lt;br /&gt;
The /etc/wpa_supplicant.conf configuration file can include multiple Wi-Fi networks. wpa_supplicant automatically selects the best network based on the order of network blocks in the configuration file, network security level, and signal strength.&lt;br /&gt;
&lt;br /&gt;
To add a second Wi-Fi network, run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that you need to use the -a option with the tee command, which will append, instead of deleting the original content, the new Wifi-network to the file.&lt;br /&gt;
Wi-Fi Security&lt;br /&gt;
&lt;br /&gt;
Do not use WPA2 TKIP or WPA2 TKIP+AES as the encryption method in your Wi-Fi router. TKIP is not considered secure anymore. You can use WPA2-AES as the encryption method.&lt;br /&gt;
Wrapping Up&lt;br /&gt;
&lt;br /&gt;
I hope this tutorial helped you connect Debian 11/10 to Wi-Fi network from the command line with WPA Supplicant. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks 🙂&lt;/div&gt;</summary>
		<author><name>Erwin</name></author>
	</entry>
</feed>