I set up two scheduled tasks, which are scheduled to restart the service, as follows:
[root@iZ94r80gdghZ tanteng]# crontab -l# 系统计划任务* */1 * * * service mariadb restart >> /home/tanteng/crontab.log* * */1 * * service php70-php-fpm restart >> /home/tanteng/crontab.log
I just put the command statements in the back of the scheduled task can be, these commands in the machine can be run, while the output recorded to the log log, but the log log does not have any content, do not know that the program is not effective, so write right?
Reply content:
I set up two scheduled tasks, which are scheduled to restart the service, as follows:
[root@iZ94r80gdghZ tanteng]# crontab -l# 系统计划任务* */1 * * * service mariadb restart >> /home/tanteng/crontab.log* * */1 * * service php70-php-fpm restart >> /home/tanteng/crontab.log
I just put the command statements in the back of the scheduled task can be, these commands in the machine can be run, while the output recorded to the log log, but the log log does not have any content, do not know that the program is not effective, so write right?
Two places you need to be aware of.
1 The service command is accessible in crontab
2 Through the restart way, the application produces the log can really record to the specified file?
1th question can be viewed /var/log/messages
and /var/spool/mails/username
log judged
The 2nd question is good to solve, direct command line service mariadb restart > ~/mariadb.log
, then connect to database, do query (generate log), and then view this file, but actually I guess there should be no.
LS says it's basically comprehensive.
Crontab, generic or when you are unsure, the command is packaged directly into an executable file and then directly crontab the executable.
Service command operation, General MARIADB and the like to go back to the configuration file, so the actual DB log output will be in the location specified in the configuration file
Service xxx Restart >> xxx.log, this inside Xxx.log is just a short message of whether the output is successful or not
Check the crontab log to see if it has been executed
Star/1 This notation superfluous, write stars
1, check the crontab log, see whether this two command execution, (execution does not necessarily succeed)
2, simple judgment, through the process of the PID judgment, whether the implementation of success, are restart command, smooth restart, the PID will change
1L basically said it.
I also said a few points:
1.直接先测试命令,看是否能使用,例如你上面的:service mariadb restart >> /home/tanteng/crontab.log2.把命令调到 * * * * * 每分钟先做一个测试,可以的话,再修改命令。
Using full path execution commands in crontab
* */1 * * * /user/lib/user/bin/service mariadb restart >> /home/tanteng/crontab.log* * */1 * * /user/lib/user/bin/service php70-php-fpm restart >> /home/tanteng/crontab.log