What Is A Cronjob

[!INFO]-
topic: πŸ–₯️ Tech
links:
source: https://devconnected.com/cron-jobs-and-crontab-on-linux-explained/
tags: #permanent-noteΒ #published

Last Modified: =dateformat(this.file.mtime, "MMM. dd, yyyy - HH:mm")


Cron is the short form for command run on notice. It is a task which is run automatically at a specific time, at a specified interval. This can range from simple shell commands to complex scripts.

Here is a short guide how to work with cronjobs:

edit cronjobs

$ crontab -e

list cronjobs (printing cron file)

$ crontab -l

edit cronjobs for specific user (in this case user www-data)

crontab -e -u www-data

Syntax for cronjobs:

# update all packages
0 3 * * * sudo apt upgrade && sudo apt -y upgrade

Structure:

.---------------- minute (0 - 59)
| .-------------- hour (0 - 23)
| | .------------ day of month (1 - 31)
| | | .---------- month (1 - 12) OR jan,feb,mar ...
| | | | .-------- day of week (0 - 6) (Sunday=0 or 7)
| | | | |
 * * * * * command to be executed