Cron Scripts Needs to be Executable

Cron scripts that are located inside the cron scheduling folders needs to adhere to these rules in order to be executed.

871 views
d

By. Jacob

Edited: 2020-09-04 11:04

In general, scripts that are supposed to be executed will also need to be marked as executable, this also goes for scripts that are evoked by cron. In addition to this, specific requirements apply for scripts located in the Debian specific scheduling folders.

In order for cron scripts located inside of the cron scheduling folders to be executed by run-parts, they will need to be owned by root, and can also not be writable by group or other. The file names of these scripts also may not contain a dot (.) character.

The restrictions apply for scripts located in the Debian and Ubuntu- specific folders:

  1. /etc/cron.monthly
  2. /etc/cron.weekly
  3. /etc/cron.daily
  4. /etc/cron.hourly

Note. This may apply to most or all Debian based distributions.

To make a script that is supposed to be run by cron executable:

sudo chmod +x /path/to/script-file.sh

Remember, files that are placed in these folders can not contain a dot character in their names. The only characters allowed are alphanumeric, hyphens and underscores: [a-zA-Z0-9_-].

If even finer control is needed, be sure to read: How to Setup Cron Jobs in Linux

Tell us what you think:

  1. Understanding file permissions in Unix / Linux based systems, and how to make files immutable.
  2. How to search a directory and subdirectories for a given string of text in Linux with the grep command.
  3. Worth knowing in order to make a bootable USB memory stick with Windows on from Linux.
  4. This is why I decided to encrypt my new Flash Drive, and why I think you should too.
  5. About the problem with using sudo with graphical programs in Linux.

More in: Linux Tutorials