Quantcast
Channel: Why crontab scripts are not working? - Ask Ubuntu
Viewing all articles
Browse latest Browse all 48

Answer by Alexandre for Why crontab scripts are not working?

$
0
0

Although you can define environment variables in your crontable, you're not in a shell script. So constructions like the following won't work:

SOME_DIR=/var/logMY_LOG_FILE=${SOME_LOG}/some_file.logBIN_DIR=/usr/local/binMY_EXE=${BIN_DIR}/some_executable_file0 10 * * * ${MY_EXE} some_param >> ${MY_LOG_FILE}

This is because variables are not interpreted in the crontable: all values are taken litterally. And this is the same if you omit the brackets.So your commands won't run, and your log files won't be written...

Instead you must define all your environment variables straight:

SOME_DIR=/var/logMY_LOG_FILE=/var/log/some_file.logBIN_DIR=/usr/local/binMY_EXE=/usr/local/bin/some_executable_file0 10 * * * ${MY_EXE} some_param >> ${MY_LOG_FILE}

Viewing all articles
Browse latest Browse all 48

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>