There is a period of time without crontab scheduled to perform tasks, this time to take advantage of the project implementation of the opportunity to further analyze the Crontab timing task settings encountered some difficult problems.
Crontab-l View the crontab information that is currently set
CRONTAB-E Editing timed tasks
Examples Show
*/1 * * * * jstack process number >> Jstack.log
The first five "*" numbers represent "minutes (0-59) hours (0-23) days (1-31) months (1-12) weeks (0-6, 0 means Sunday)
In the example above, the jstack is executed every other minute and the result of the operation is output to Jstack.log.
A small partner may say that such execution may not succeed Oh, then the question came, why not succeed?
If you are currently using the root user, and if the environment variables are configured with the Java environment variables, then it is no problem to execute the above crontab, but if you use other new users, although you may also have configured the Java environment variables
However, Crontab does not read the contents of your other user environment variables, so the solution is to save the execution command as a shell script, display the environment variables executing the current user in the script, and then run the command output
1 # !/bin/bash 2 . /etc/profile3 . ~/. Bash_profile4echo get Java process number 5$"6 ${pid}7Echo starts recording jstack information and outputs Jstack.log8${pid} to the root directory >> Jstack.log
Let's say the above code is saved to the jstack.sh file so that when the crontab is set, it is directly
*/1 * * * */home/test/jstack.sh
This will allow you to observe the growth of the Jstack.log file, thus avoiding the problem of using absolute paths.
Crontab the reason that the shell script failed to execute at timed time