The software utility cron also known as cron job is a time-based job scheduler in Unix-like computer operating systems.
Normally the crontab util is located under /etc/crontab
Locate your crontab and enter with your default editor
vim /etc/crontab
In this case the script “test.sh” it’s executed with “root” user permission, every minutes
SHELL=/bin/bash
MAILTO=admin@name.tld
PATH=/sbin:/bin:/usr/sbin:/usr/bin
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
* * * * * root /opt/scripts/test.sh
If you have in your server setup postfix or another mail server, it will send automatically the mail and the end of the script execution
Here an useful tool to schedule properly your scripts https://crontab.guru
0 Comments