定时任务顾名思义就是在某一时间点自动进行任务操作。
在做Pgsql的备份利用crontab进行定时操作, 使用起来比较方便。故分享
具体的定时编辑命令:crontab -e
首先从crontab的文件分析使用策略,root用户下,在/etc下有一个文件crontab,其内容如下
[root@myzk ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# 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
该
文件下的前四行内容为crontab的环境变量,SHELL变量的值指定系统使用的SHELL环境(该样例为bash
shell),PATH变量定义了执行命令的路径。Cron的输出以电子邮件的形式发给MAILT