$ ls -l /etc/crontab
-rw-r--r-- 1 root root 701 Jan 11 11:04 /etc/crontab
-rw-r--r-- 1 root root 701 Jan 11 11:04 /etc/crontab
$ cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# 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
30 * * * * ec2-user /home/user/cicd.sh
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# 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
30 * * * * ec2-user /home/user/cicd.sh
# Directories of different times.
/etc/cron.d/ #all kind files
/etc/cron.hourly/
/etc/cron.daily/
/etc/cron.weekly/
/etc/cron.monthly/
#user list of allow or deny.
/etc/cron.allow
/etc/cron.deny
/etc/cron.deny
#check at service
$ systemctl status atd
● atd.service - Job spooling tools
Loaded: loaded (/usr/lib/systemd/system/atd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-01-17 09:01:43 JST; 55min ago
Main PID: 4523 (atd)
Tasks: 1
Memory: 484.0K
CGroup: /system.slice/atd.service
mq4523 /usr/sbin/atd -f
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
#run atd if not started.
$ systemctl start atd
#auto started with os.
$ systemctl enable atd
#Example: run backup.sh at 2016/10/17 19:15
$ at "19:15 17.10.16" -f backup.sh
$ at 10pm -f backup.sh #run backup.sh at 22:00
$ at now + 4days backup.sh #run at the same time after 4days.
$ at 9pm + 3weeks #run at 21:00 after 3weeks
$ at now + 4days backup.sh #run at the same time after 4days.
$ at 9pm + 3weeks #run at 21:00 after 3weeks
没有评论:
发表评论