Instructions on shell programming and cron scheduled tasks
Source: Internet
Author: User
For more information about shell programming and cron planning tasks-Linux general technology-Linux programming and kernel, see the following. Recently, a server encountered a problem (the specific cause has not been identified. The initial diagnosis is that the php load is too high, leading to network congestion, and eventually the network crashes and cannot access the Internet. This is an out-of-the-box question. it has nothing to do with this topic. in this case, the server is disconnected from the network and cannot connect to the network. you can run the service network restart command to restart the network service.
Therefore, I wrote a script to check the network every two minutes. when the Gateway cannot be pinged, the network disconnection log is recorded and the network service (service network restart) is restarted ), ping rules only record logs.
Now the problem is that if you manually run the script, you can perform normal detection and record operations, or you can restart the network service if the network is disconnected. However, after you add the script to a scheduled task, everything is fine, only the key service network restart cannot take effect! (The log has a network disconnection record)
The script is relatively simple and will not be explained. The key is row 8. I want to output the running result to the off_log file. However, I only view the off_log with the offline record. I have not restarted the network service, and I have not restarted the network service!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.