linux执行定时脚本

 

 

1、创建脚本文件

vim a.sh

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

ifconfig

 

2、增加执行权限

chmod +x a.sh

chmod +x a.sh

 

3、查看执行顺序

cat /etc/crontab

# 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

 

4、查看执行脚本

crontab -l

0 0 6 * * /www/wwwroot/oa_py/oa_dev/.commands.sh >> /www/wwwroot/oa_py/oa_dev/.commands.log 2>&1
0 0 6 * * /www/wwwroot/oa_py/oa_prod/.commands.sh >> /www/wwwroot/oa_py/oa_prod/.commands.log 2>&1

 

5、增加执行脚本

crontab -e

3 * * * * /www/wwwroot/oa_py/script/oa_dev/a.sh >> /www/wwwroot/oa_py/script/oa_dev/a.log 2>&1

1 6 * * * /www/wwwroot/oa_py/oa_dev/.commands.sh >> /www/wwwroot/oa_py/oa_dev/.commands.log 2>&1
1 6 * * * /www/wwwroot/oa_py/oa_prod/.commands.sh >> /www/wwwroot/oa_py/oa_prod/.commands.log 2>&1
3 * * * * /www/wwwroot/oa_py/script/oa_dev/a.sh >> /www/wwwroot/oa_py/script/oa_dev/a.log 2>&1

 

posted @ 2023-02-07 11:10  陨落&新生  阅读(53)  评论(0编辑  收藏  举报