https://mmonit.com/monit/
https://mmonit.com/wiki/Monit/ConfigurationExamples
https://mmonit.com/monit/documentation/monit.html
https://mmonit.com/
check directory bin with path /bin
if failed permission 755 then unmonitor
if failed uid 0 then unmonitor
if failed gid 0 then unmonitor
check filesystem dev_sda with path /dev/sda
#if failed permission 660 then unmonitor
#if failed uid "huangjian" then unmonitor
#if failed gid "root" then unmonitor
if space usage > 80% for 5 times within 15 cycles then alert
if space usage > 90% then alert
if inode usage > 90% then alert
if read rate > 1 MB/s for 5 cycles then alert
if read rate > 500 operations/s for 5 cycles then alert
if write rate > 1 MB/s for 5 cycles then alert
if write rate > 500 operations/s for 5 cycles then alert
if service time > 10 milliseconds for 3 times within 5 cycles then alert
check network enp0s31f6 with interface enp0s31f6
if failed link then alert
if changed link then alert
if saturation > 90% then alert
if download > 10 MB/s then alert
if total uploaded > 10 GB in last hour then alert
if total downloaded > 10 GB in last hour then alert
check file nginxlog with path /home/huangjian/local/openresty/nginx/logs/access.log
if size > 1 GB then alert
group nginx
check file nginxpid with path /home/huangjian/local/openresty/nginx/logs/nginx.pid
if changed timestamp then alert
if size == 0 then alert
group nginx
check process nginxbin with pidfile /home/huangjian/local/openresty/nginx/logs/nginx.pid
if changed pid then alert
if changed ppid then alert
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then alert
if totalmem > 1024.0 MB for 5 cycles then alert
if children > 250 then alert
group nginx
check host baidu with address www.baidu.com
if failed ping count 5 size 128 with timeout 10 seconds then alert
check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/ssh start"
stop program "/etc/init.d/ssh stop"
if failed port 22 protocol ssh then restart
check system $HOST
if loadavg (5min) > 6 then alert
if loadavg (15min) > 5 then alert
if memory usage > 80% for 4 cycles then alert
if swap usage > 20% for 4 cycles then alert
# Test the user part of CPU usage
if cpu usage (user) > 80% for 2 cycles then alert
# Test the system part of CPU usage
if cpu usage (system) > 20% for 2 cycles then alert
# Test the i/o wait part of CPU usage
if cpu usage (wait) > 80% for 2 cycles then alert
# Test CPU usage including user, system and wait. Note that
# multi-core systems can generate 100% per core
# so total CPU usage can be more than 100%
if cpu usage > 200% for 4 cycles then alert
master 进程不见了。而且监听的端口也变成了 worker 进程在监听。
# ps -ef | grep nginx
root 7215 7180 0 07:46 pts/0 00:00:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn nginx
www-data 9824 1 0 Jan11 ? 00:12:10 nginx: worker process
www-data 9825 1 0 Jan11 ? 00:15:01 nginx: worker process
# netstat -ltnp | grep nginx
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 9824/nginx: worker
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9824/nginx: worker
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 9824/nginx: worker
export TIME_STYLE='+%Y/%m/%d %H:%M:%S'
创建一个 foo.txt 文件
$ touch foo.txt
$ echo "hello" > foo.txt
$ cat foo.txt
hello
foo.txt 文件的 inode 是 13
$ ls -lhi foo.txt
13 -rw-rw-r-- 1 huangjian huangjian 6 Feb 22 13:56 foo.txt
$ stat foo.txt
File: 'foo.txt'
Size: 6 Blocks: 8 IO Block: 4096 regular file
Device: 800h/2048d Inode: 13 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/huangjian) Gid: ( 1000/huangjian)
Access: 2019-02-22 13:56:35.097721182 +0800
Modify: 2019-02-22 13:56:31.645684665 +0800
Change: 2019-02-22 13:56:31.645684665 +0800
Birth: -
cp 拷贝出来的文件,inode 的值改变了。
$ cp foo.txt foo.txt.cp
$ stat foo.txt.cp
File: 'foo.txt.cp'
Size: 6 Blocks: 8 IO Block: 4096 regular file
Device: 800h/2048d Inode: 15 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/huangjian) Gid: ( 1000/huangjian)
Access: 2019-02-22 13:58:18.050807588 +0800
Modify: 2019-02-22 13:58:18.050807588 +0800
Change: 2019-02-22 13:58:18.050807588 +0800
Birth: -
给 foo.txt 创建一个硬链接,inode 不变
$ ln foo.txt foo.txt.hardlink
$ stat foo.txt.hardlink
File: 'foo.txt.hardlink'
Size: 6 Blocks: 8 IO Block: 4096 regular file
Device: 800h/2048d Inode: 13 Links: 2
Access: (0664/-rw-rw-r--) Uid: ( 1000/huangjian) Gid: ( 1000/huangjian)
Access: 2019-02-22 13:56:35.097721182 +0800
Modify: 2019-02-22 13:56:31.645684665 +0800
Change: 2019-02-22 13:58:38.651024368 +0800
Birth: -
给 foo.txt 创建一个软链接,inode 改变了
$ ln -s foo.txt foo.txt.softlink
$ stat foo.txt.softlink
File: 'foo.txt.softlink' -> 'foo.txt'
Size: 7 Blocks: 0 IO Block: 4096 symbolic link
Device: 800h/2048d Inode: 16 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 1000/huangjian) Gid: ( 1000/huangjian)
Access: 2019-02-22 13:59:06.099312909 +0800
Modify: 2019-02-22 13:59:00.707256254 +0800
Change: 2019-02-22 13:59:00.707256254 +0800
Birth: -
mv 移动文件的时候,inode 不变。但是如果系统中有多个硬盘,mv 的时候是从一个硬盘移动到另一个硬盘的话,inode 会改变。
$ ls -lhi foo.txt*
13 -rw-rw-r-- 2 huangjian huangjian 6 Feb 22 13:56 foo.txt
15 -rw-rw-r-- 1 huangjian huangjian 6 Feb 22 13:58 foo.txt.cp
13 -rw-rw-r-- 2 huangjian huangjian 6 Feb 22 13:56 foo.txt.hardlink
16 lrwxrwxrwx 1 huangjian huangjian 7 Feb 22 13:59 foo.txt.softlink -> foo.txt
$ mv foo.txt foo.txt.bar
$ ls -lhi foo.txt*
13 -rw-rw-r-- 2 huangjian huangjian 6 Feb 22 13:56 foo.txt.bar
15 -rw-rw-r-- 1 huangjian huangjian 6 Feb 22 13:58 foo.txt.cp
13 -rw-rw-r-- 2 huangjian huangjian 6 Feb 22 13:56 foo.txt.hardlink
16 lrwxrwxrwx 1 huangjian huangjian 7 Feb 22 13:59 foo.txt.softlink -> foo.txt
修改 foo.txt.bar 的内容,硬链接也会改变,因为他们的 inode 是相同的。
$ echo "world" > foo.txt.bar
$ cat foo.txt.hardlink
world
$ select-editor
Select an editor. To change later, run 'select-editor'.
1. /bin/ed
2. /bin/nano <---- easiest
3. /usr/bin/code
4. /usr/bin/vim.basic
5. /usr/bin/vim.tiny
Choose 1-5 [2]: 4
编辑当前用户的定时任务
crontab -e
如果当前用户为 huangjian,crontab -u huangjian -e
和 crontab -e
是一样的。
sudo crontab -u root -e
编辑 root 用户的定时任务
编辑好之后,保存了,就生效了。如果要删除某个定时任务,也用 crontab -e
这个
命令打开 crontab 文件,删除掉了,再保存了就好了。
$ crontab -l
*/1 * * * * /home/huangjian/local/BashUtils/nginx/rotate.sh
这个命令慎用!!!
crontab -r 删除掉当前用户的所有定时任务
sudo crontab -u root -r 删除掉 root 用户的所有定时任务
Field name | Allowed values | Allowed special characters |
---|---|---|
Minutes | 0-59 | * / , - |
Hours | 0-23 | * / , - |
Day of month | 1-31 | * / , - ? |
Month | 1-12 or JAN-DEC | * / , - |
Day of week | 0-6 or SUN-SAT | * / , - ? |
# Field name | Allowed values | Allowed special characters
# ---------- | -------------- | --------------------------
# Minutes | 0-59 | * / , -
# Hours | 0-23 | * / , -
# Day of month | 1-31 | * / , - ?
# Month | 1-12 or JAN-DEC | * / , -
# Day of week | 0-6 or SUN-SAT | * / , - ?
#
# * 表示匹配所有的值。
# 比如说 Minutes 使用 * 表示每分钟。
# Hours 使用 * 表示每小时。
# Month 使用 * 表示每个月。
#
# / 表示范围和间隔。
# Minutes 使用 3-59/15 表示从第 3 分钟到第 59 分钟,每隔 15 分钟。
# 每天的 0 点,1 点,2 点....时执行命令
0 0 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_24_00.txt
0 1 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_01_00.txt
0 2 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_02_00.txt
0 3 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_03_00.txt
0 4 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_04_00.txt
0 5 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_05_00.txt
0 6 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_06_00.txt
0 7 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_07_00.txt
0 8 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_08_00.txt
0 9 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_09_00.txt
0 10 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_10_00.txt
0 11 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_11_00.txt
0 12 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_12_00.txt
0 13 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_13_00.txt
0 14 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_14_00.txt
0 15 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_15_00.txt
0 16 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_16_00.txt
0 17 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_17_00.txt
0 18 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_18_00.txt
0 19 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_19_00.txt
0 20 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_20_00.txt
0 21 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_21_00.txt
0 22 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_22_00.txt
0 23 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_23_00.txt
# 每天的 7:50 执行命令
50 7 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_07_50.txt
# 每天的 22:50 执行命令
50 22 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_22_50.txt
# 每隔 1 分钟,2 分钟,3 分钟,4 分钟执行命令
*/1 * * * * echo `date` >> /home/huangjian/crontab_demo/every_1_minute.txt
*/2 * * * * echo `date` >> /home/huangjian/crontab_demo/every_2_minute.txt
*/3 * * * * echo `date` >> /home/huangjian/crontab_demo/every_3_minute.txt
*/4 * * * * echo `date` >> /home/huangjian/crontab_demo/every_4_minute.txt
*/5 * * * * echo `date` >> /home/huangjian/crontab_demo/every_5_minute.txt
*/6 * * * * echo `date` >> /home/huangjian/crontab_demo/every_6_minute.txt
*/7 * * * * echo `date` >> /home/huangjian/crontab_demo/every_7_minute.txt
# 每隔 1 分钟执行一次命令
* * * * * echo `date` >> /home/huangjian/crontab_demo/every_1_minute_method1.txt
# 每隔 1 小时,2 小时,3 小时,4 小时,5 小时,6 小时,7 小时执行命令
0 */1 * * * echo `date` >> /home/huangjian/crontab_demo/every_1_hours.txt
0 */2 * * * echo `date` >> /home/huangjian/crontab_demo/every_2_hours.txt
0 */3 * * * echo `date` >> /home/huangjian/crontab_demo/every_3_hours.txt
0 */4 * * * echo `date` >> /home/huangjian/crontab_demo/every_4_hours.txt
0 */5 * * * echo `date` >> /home/huangjian/crontab_demo/every_5_hours.txt
0 */6 * * * echo `date` >> /home/huangjian/crontab_demo/every_6_hours.txt
0 */7 * * * echo `date` >> /home/huangjian/crontab_demo/every_7_hours.txt
# 每小时的第 0 分钟,第 1 分钟,第 2 分钟,第 3 分钟,.... 执行命令
0 * * * * echo `date` >> /home/huangjian/crontab_demo/every_hour_0th.txt
1 * * * * echo `date` >> /home/huangjian/crontab_demo/every_hour_1th.txt
2 * * * * echo `date` >> /home/huangjian/crontab_demo/every_hour_2th.txt
3 * * * * echo `date` >> /home/huangjian/crontab_demo/every_hour_3th.txt
4 * * * * echo `date` >> /home/huangjian/crontab_demo/every_hour_4th.txt
5 * * * * echo `date` >> /home/huangjian/crontab_demo/every_hour_5th.txt
6 * * * * echo `date` >> /home/huangjian/crontab_demo/every_hour_6th.txt
7 * * * * echo `date` >> /home/huangjian/crontab_demo/every_hour_7th.txt
# 每天的 6 点到 12 点之间,每隔 3 小时执行命令
0 6-12/3 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_6-12_hour_every_3_hour.txt
# 每天的 7 点到 12 点之间,每隔 3 小时执行命令
0 7-12/3 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_7-12_hour_every_3_hour.txt
# 每天的 0 点 20 分,2 点 20 分,4 点 20 分,.... 执行命令
20 0-23/2 * * * echo `date` >> /home/huangjian/crontab_demo/every_2_hour_20th_minute.txt
# 每月的 1 号,2 号,3 号,4 号,5 号,6 号,7 号执行命令
0 0 1 * * echo `date` >> /home/huangjian/crontab_demo/everymonth_1.txt
0 0 2 * * echo `date` >> /home/huangjian/crontab_demo/everymonth_2.txt
0 0 3 * * echo `date` >> /home/huangjian/crontab_demo/everymonth_3.txt
0 0 4 * * echo `date` >> /home/huangjian/crontab_demo/everymonth_4.txt
0 0 5 * * echo `date` >> /home/huangjian/crontab_demo/everymonth_5.txt
0 0 6 * * echo `date` >> /home/huangjian/crontab_demo/everymonth_6.txt
0 0 7 * * echo `date` >> /home/huangjian/crontab_demo/everymonth_7.txt
# 每月的 1 号和 15 号执行命令
0 0 1,15 * * echo `date` >> /home/huangjian/crontab_demo/everymonth_1_and_15.txt
# 每周的的周一到周五的 3 点钟执行命令
0 3 * * 1-5 echo `date` >> /home/huangjian/crontab_demo/week_1-5_everyday_3th_hour.txt
# 在周六和周天的 00:00 执行命令
0 0 * * 0,6 echo `date` >> /home/huangjian/crontab_demo/week_6-7_00_00.txt
# 在每个月的 1、11、21、31 号,的 6:30 分执行命令
30 6 */10 * * echo `date` >> /home/huangjian/crontab_demo/everymonth_1_11_21_31.txt
# 在 23 点,0 点到 7 点,每隔 1 分钟执行命令
* 23,0-7/1 * * * echo `date` >> /home/huangjian/crontab_demo/hour_0-7_23_every_minute.txt
# 在 23 点,0 点,2 点,4 点,6 点,每隔 1 分钟执行命令
* 23,0-7/2 * * * echo `date` >> /home/huangjian/crontab_demo/hour_0_2_4_6_23_every_minute.txt
# 每天的 3 点到 5 点,17 点到 20 点,每隔 30 分钟执行命令
*/30 3-5,17-20 * * * echo `date` >> /home/huangjian/crontab_demo/hour_3-5_17-20_every_30_minute.txt
# 每年的 8 月 20 号的 00:00 执行命令
0 0 20 8 * echo `date` >> /home/huangjian/crontab_demo/month_8_20th.txt
注意: 在有的 crontab 上,配置里面如果有空行也会报错,实在是太坑了。
可以使用 vim 的命令 :g/^$/d
来删除所有空行。
*/1 * * * * test.sh
上面这么写是有问题的,因为要用绝对路径,修改如下:
*/1 * * * * /bin/bash /home/huangjian/test.sh
*/1 * * * * echo `date` >> /home/huangjian/foo.txt
0 0 * * * test.sh
# 每隔 1 分钟执行命令
*/1 * * * * echo `date` >> /home/huangjian/crontab_demo/every_1_minute.txt
Wed Sep 11 12:53:01 UTC 2019
Wed Sep 11 12:54:01 UTC 2019
Wed Sep 11 12:55:01 UTC 2019
Wed Sep 11 12:56:01 UTC 2019
Wed Sep 11 12:57:01 UTC 2019
Wed Sep 11 12:58:01 UTC 2019
Wed Sep 11 12:59:01 UTC 2019
Wed Sep 11 13:00:01 UTC 2019
Wed Sep 11 13:01:01 UTC 2019
Wed Sep 11 13:02:01 UTC 2019
Wed Sep 11 13:03:01 UTC 2019
你会发现,这个不仅仅是只隔两分钟,而且分钟数也是 2 的倍数。
# 每隔 2 分钟执行命令
*/2 * * * * echo `date` >> /home/huangjian/crontab_demo/every_2_minute.txt
Wed Sep 11 12:44:01 UTC 2019
Wed Sep 11 12:46:02 UTC 2019
Wed Sep 11 12:48:01 UTC 2019
Wed Sep 11 12:50:01 UTC 2019
Wed Sep 11 12:52:01 UTC 2019
Wed Sep 11 12:54:01 UTC 2019
Wed Sep 11 12:56:01 UTC 2019
Wed Sep 11 12:58:01 UTC 2019
Wed Sep 11 13:00:01 UTC 2019
Wed Sep 11 13:02:01 UTC 2019
Wed Sep 11 13:04:01 UTC 2019
Wed Sep 11 13:06:01 UTC 2019
Wed Sep 11 13:08:01 UTC 2019
Wed Sep 11 13:10:01 UTC 2019
Wed Sep 11 13:12:01 UTC 2019
Wed Sep 11 13:14:01 UTC 2019
Wed Sep 11 13:16:01 UTC 2019
Wed Sep 11 13:18:01 UTC 2019
每隔 3 分钟,并且分钟数也是 3 的倍数。
# 每隔 3 分钟执行命令
*/3 * * * * echo `date` >> /home/huangjian/crontab_demo/every_3_minute.txt
Wed Sep 11 12:42:01 UTC 2019
Wed Sep 11 12:45:02 UTC 2019
Wed Sep 11 12:48:01 UTC 2019
Wed Sep 11 12:51:01 UTC 2019
Wed Sep 11 12:54:01 UTC 2019
Wed Sep 11 12:57:01 UTC 2019
Wed Sep 11 13:00:01 UTC 2019
Wed Sep 11 13:03:01 UTC 2019
Wed Sep 11 13:06:01 UTC 2019
Wed Sep 11 13:09:01 UTC 2019
Wed Sep 11 13:12:01 UTC 2019
Wed Sep 11 13:15:01 UTC 2019
# 每隔 4 分钟执行命令
*/4 * * * * echo `date` >> /home/huangjian/crontab_demo/every_4_minute.txt
Wed Sep 11 12:44:01 UTC 2019
Wed Sep 11 12:48:01 UTC 2019
Wed Sep 11 12:52:01 UTC 2019
Wed Sep 11 12:56:01 UTC 2019
Wed Sep 11 13:00:01 UTC 2019
Wed Sep 11 13:04:01 UTC 2019
Wed Sep 11 13:08:01 UTC 2019
Wed Sep 11 13:12:01 UTC 2019
# 每隔 5 分钟执行命令
*/5 * * * * echo `date` >> /home/huangjian/crontab_demo/every_5_minute.txt
Wed Sep 11 12:45:02 UTC 2019
Wed Sep 11 12:50:01 UTC 2019
Wed Sep 11 12:55:01 UTC 2019
Wed Sep 11 13:00:01 UTC 2019
Wed Sep 11 13:05:01 UTC 2019
Wed Sep 11 13:10:01 UTC 2019
Wed Sep 11 13:15:01 UTC 2019
# 每隔 6 分钟执行命令
*/6 * * * * echo `date` >> /home/huangjian/crontab_demo/every_6_minute.txt
Wed Sep 11 12:42:01 UTC 2019
Wed Sep 11 12:48:01 UTC 2019
Wed Sep 11 12:54:01 UTC 2019
Wed Sep 11 13:00:01 UTC 2019
Wed Sep 11 13:06:01 UTC 2019
Wed Sep 11 13:12:01 UTC 2019
Wed Sep 11 13:18:01 UTC 2019
Wed Sep 11 13:24:01 UTC 2019
认真观察这个情况,你会发现,在 56 分的时候,下一个就变成了 00 了。
所以,这并不是严格的每隔 7 分钟执行一次。
# 每隔 7 分钟执行命令
*/7 * * * * echo `date` >> /home/huangjian/crontab_demo/every_7_minute.txt
Wed Sep 11 12:42:01 UTC 2019
Wed Sep 11 12:49:01 UTC 2019
Wed Sep 11 12:56:01 UTC 2019
Wed Sep 11 13:00:01 UTC 2019
Wed Sep 11 13:07:01 UTC 2019
Wed Sep 11 13:14:01 UTC 2019
Wed Sep 11 13:21:01 UTC 2019
Wed Sep 11 13:28:01 UTC 2019
Wed Sep 11 13:35:01 UTC 2019
Wed Sep 11 13:42:01 UTC 2019
Wed Sep 11 13:49:01 UTC 2019
Wed Sep 11 13:56:01 UTC 2019
Wed Sep 11 14:00:01 UTC 2019
Wed Sep 11 14:07:01 UTC 2019
# 每小时的第 0 分钟执行命令
0 * * * * echo `date` >> /home/huangjian/crontab_demo/every_hour_0th.txt
Wed Sep 11 13:00:01 UTC 2019
Wed Sep 11 14:00:01 UTC 2019
Wed Sep 11 15:00:01 UTC 2019
Wed Sep 11 16:00:01 UTC 2019
Wed Sep 11 17:00:01 UTC 2019
Wed Sep 11 18:00:01 UTC 2019
Wed Sep 11 19:00:01 UTC 2019
Wed Sep 11 20:00:01 UTC 2019
# 每小时的第 1 分钟执行命令
1 * * * * echo `date` >> /home/huangjian/crontab_demo/every_hour_1th.txt
Wed Sep 11 13:01:01 UTC 2019
Wed Sep 11 14:01:01 UTC 2019
Wed Sep 11 15:01:01 UTC 2019
Wed Sep 11 16:01:01 UTC 2019
Wed Sep 11 17:01:01 UTC 2019
Wed Sep 11 18:01:01 UTC 2019
Wed Sep 11 19:01:01 UTC 2019
# 每小时的第 2 分钟执行命令
2 * * * * echo `date` >> /home/huangjian/crontab_demo/every_hour_2th.txt
Wed Sep 11 13:02:01 UTC 2019
Wed Sep 11 14:02:01 UTC 2019
Wed Sep 11 15:02:01 UTC 2019
Wed Sep 11 16:02:01 UTC 2019
Wed Sep 11 17:02:01 UTC 2019
Wed Sep 11 18:02:02 UTC 2019
Wed Sep 11 19:02:01 UTC 2019
# 每天的 1 点时执行命令
0 1 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_01_00.txt
Thu Sep 12 01:00:01 UTC 2019
Fri Sep 13 01:00:01 UTC 2019
Sat Sep 14 01:00:01 UTC 2019
Sun Sep 15 01:00:01 UTC 2019
Mon Sep 16 01:00:01 UTC 2019
# 每天的 2 点时执行命令
0 2 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_02_00.txt
Thu Sep 12 02:00:01 UTC 2019
Fri Sep 13 02:00:01 UTC 2019
Sat Sep 14 02:00:01 UTC 2019
Sun Sep 15 02:00:01 UTC 2019
Mon Sep 16 02:00:01 UTC 2019
# 每天的 0 点时执行命令
0 0 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_24_00.txt
Thu Sep 12 00:00:01 UTC 2019
Fri Sep 13 00:00:01 UTC 2019
Sat Sep 14 00:00:01 UTC 2019
Sun Sep 15 00:00:01 UTC 2019
Mon Sep 16 00:00:01 UTC 2019
# 每天的 6 点到 12 点之间,每隔 3 小时执行命令
0 6-12/3 * * * echo `date` >> /home/huangjian/crontab_demo/everyday_6-12_hour_every_3_hour.txt
Thu Sep 12 06:00:01 UTC 2019
Thu Sep 12 09:00:01 UTC 2019
Thu Sep 12 12:00:01 UTC 2019
Fri Sep 13 06:00:01 UTC 2019
Fri Sep 13 09:00:01 UTC 2019
Fri Sep 13 12:00:01 UTC 2019
Sat Sep 14 06:00:01 UTC 2019
Sat Sep 14 09:00:01 UTC 2019
Sat Sep 14 12:00:02 UTC 2019