使用crontab来解决linux下定时任务,创建一个shell文件写下执行的命令
crontab -e 来增加需要执行的shell文件
crontab-l显示是否增加成功,
格式如下图,代表执行命令的时间为凌晨12点10分且每日执行
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
10 00 * * * /root/java/t.sh