Exclude ideas
1. Make sure that the boot from Kai crond service is started and is currently
# centos 7 systemctl status crond systemctl start crond # centos 5,6 service crond status chkconfig crond on
2. Check the mail error messages inside information about the scheduled task.
Borrowing the network over the upper diagram,
In this case, the general configuration of these environments in the profile file, may be the next source in a script file, let it take effect, or the corresponding configuration script written to come inside.
source /etc/profile
3. The script inside the program is not in the PATH command inside.
Inside the command script execution, not in the environment variable plan tasks performed there, you need to add a command to write the whole path or paths.
# Get all PATH in the terminal can perform, write a script
echo $ PATH
/ usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / usr / local / PHP / bin : / usr / local / Docker / bin:. / usr / local / the Java / jdk1 8.0_191 / bin:. / usr / local / the Java / jdk1 8.0_191 / jre / bin: / usr / local / Flume / bin: / usr / local / Go / bin: / usr / local / Go / bin: / root / bin # add the following lines similar to PATH = / usr / local / bin in the implementation of the script: $ PATH
4. Alternatively bash
Plans to use crontab -e to edit configuration line, the command is limited, redirection and special symbols are not supported, these are offered bash, you can use the following way configuration.
# add by zhaojiedi 2019.08.30
14 * * * * bash /usr/local/bin/backup_k8s.sh
5. Under the planned task script line package
We plan to task row, and the write command if a long date with a few commands, suggested that these commands written to a new file to go inside, scheduled tasks command line to write the new file as a command.
# Originally planned task row
* * * * cd / Home / Barry / top800 / TOP10 / top10_fruits / && ./top10_all. SH
# rewritten echo " cd / Home / Barry / top800 / TOP10 / top10_fruits / && ./top10_all. SH "> / usr / local / bin / TOP10. SH * * * * * bash / usr / local / bin / TOP10. SH
And finally put a complete scheduled tasks script points