crontab does not execute shell scripts

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux3/4/5
  • cron (Any version)

Issue

  • crontab does not execute sh scripts
  • The script works fine if it manually ran from either its own directory or another directory.
  • However when script added to /etc/crontab, it seems to run at the scheduled time but the results or output is null
  • According to /var/log/cron the script runs, and the permissions seem ok

Here is hte the syntax used for the entry in /etc/crontab

13 0 *** root run-parts /scripts/ftp.sh 

And  the permissions on the script is :

-rwxr--r-- 1 root root 1906 May 12 10:44 /scripts/ftp.sh 

Resolution

  • Either remove the run-parts or point run-parts to the directory which contains the script(s) that needs to be executed.
For example:
    13 0 *** /scripts/ftp.sh 

Root Cause

  • run-parts expects a directory name which contains the script(s) as the arguments, hence pointing run-parts to a script will not work.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments