Cron Tutorial | How To Use Cron to Automate Tasks on Ubuntu 18.04

Опубликовано: 11 Январь 2025
на канале: Explained Easy
1,792
14

Cron Tutorial | How To Use Cron to Automate Tasks on Ubuntu 18.04

Beginner guide on how to use cron on ubuntu linux

00:00:00 - Intro
0:01:11 - Prerequisites
0:01:54 - Installing Cron
0:03:25 - Understanding How Cron Works
0:05:41 - Managing Crontabs
0:10:19 - Managing Cron Job Output
0:12:47 - Restricting Access
0:15:23 - Special Syntax
0:16:21 - Conclusion

Commands:
sudo apt update
sudo apt install cron
sudo systemctl enable cron
crontab -e
Edit this file to introduce tasks to be run by cron.
#
Each task to run has to be defined through a single line
indicating with different fields when the task will be run
and what command to run for the task
#
To define the time you can provide concrete values for
minute (m), hour (h), day of month (dom), month (mon),
and day of week (dow) or use '*' in these fields (for 'any').#
Notice that tasks will be started based on the cron's system
daemon's notion of time and timezones.
#
Output of the crontab jobs (including errors) is sent through
email to the user the crontab file belongs to (unless redirected).
#
For example, you can run a backup of all your user accounts
at 5 a.m every week with:
0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
For more information see the manual pages of crontab(5) and cron(8)
#
m h dom mon dow command
crontab -l
crontab -r
crontab -r -i
sudo echo ALL (MORE SIGN MORE SIGN)/etc/cron.deny
sudo echo root (MORE SIGN MORE SIGN)/etc/cron.allow
sudo crontab -u sammy -e