Linux crontab can not execute scripts associated

Linux system provides a cron the good stuff to help system or regular users to perform tasks is very convenient, but sometimes obviously perform a separate script is ok, which is not added to the crontab run (can be added via crontab -e, but after the restart seemingly crontab which has returned to its original, or directly modify / etc / crontabs / root, under cron or crontab -e and then restart to take effect q), online users also set out a variety of reasons, the main You are the following:

1. The execution of the script permissions issue

   Solution: chmod 777 xxx.sh, 777 note is that all of the permissions given to the script, there are risks

2. execution path or crontab script written inside it is best to write the absolute path, otherwise it will lead to bash script can not be found

3. Almost ditto, name careless execution of the script and crontab written inside inconsistent, good reflection -

4. Reference problem of third-party libraries, if you script using third-party libraries, have a good look is not used in the system default, it is not then have to set about (a specific degree of your mother or Google)

5. Environment Variables

  Workaround: Add the following to the crontab / root file above:

  SHELL=/bin/bash
  PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
  MAILTO=root
  HOME=/

Annex: https://crontab.guru/#*/20_*_*_*_*  

 

Released five original articles · won praise 0 · Views 252

Guess you like

Origin blog.csdn.net/DIANZI520SUA/article/details/102543230