版权声明:Summer https://blog.csdn.net/csdnyanglei/article/details/82746085
参考:
crontab命令,一般运维需要周期性的执行某个脚本时,会使用到该命令。
常用命令
-
#打印已配置的cron任务 crontab -l #进入编辑界面 crontab -e
环境变量
-
vim /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
- crontab 有自己的PATH路径,默认只加了bin相关的环境变量。
- 在执行自己的脚本时,命令有可不在bin中,这时,执行自然会报找不到命令。
- 解决方法,推进采用在脚本中加入命令的路径到PATH中,
-
PATH="$PATH:/data/XXX/XXX/bin/"