This is because you need to create a timed task to determine the status of the SNMP service. The
is judged by the following code
tmp= '/etc/init.d/snmpd status ' snmpd_status = ' echo $tmp | grep -Eo ' running ' ' if [ $snmpd _status = ' Running " ] then snmpd_status=" Running "else snmpd_ Status= "Stop" fiecho $snmpd _status
Note: The system is Red Hat 5.7 and 6.5
The
Now SNMPD service is in normal operation.
I did this by manually executing the script, and the result was running
But as long as I put it in crontab, it was a stop
.
Later, I printed every variable in the script to see, found that the language environment for the crontab operation is Chinese.
But my export is obviously in English.
I didn't think of it at first, because I did it manually and crontab used the root account
After I joined the export in front of the script Leng= "en_US", after the script execution ring language is set to English, the result of execution is normal.
For the speech variables in the environment variables, do not know why it appears in such cases, there is time to study under. If any of the great gods know, please point twos
This article is from the "mi-can have" blog, be sure to keep this source http://michankong.blog.51cto.com/1464983/1894694
About Linux under crontab when the script executes, the value obtained is incorrect