Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm having a ridiculous time with a cron not running, and there are no errors showing up in the cron log. I'm running centos5 i386, and the following script will run absolutely perfeclty when running from command, however, in cron it does not work. I've read on many forum posts that sometimes you have to set the PATH since cron does not see the same directory listing as a user, however, I do not think that is the case here since my other cron script with the same directory structure works fine.
I'm running the following shell script (seen as generate in cron below):
You will notice the .sh is missing on generate because I have read a few other threads where people said sometimes cron doesn't like the .sh extension when executing a script. So I've tried using PATH, tried removing and using the .sh extension, but still no luck. elmador_backup.sh works perfectly fine, however, map generate does not.
Does anyone have any suggestions on why this may not be running? I want it to run every minute.
"set -e" means "exit immediately if a command exits with a non-zero status". Try commenting out that line or replace temporarily for debugging purposes with "set -vx"?
"set -e" means "exit immediately if a command exits with a non-zero status". Try commenting out that line or replace temporarily for debugging purposes with "set -vx"?
That was it, it worked after changing from set -e to set -vx.
Just out of curiosity, is there another place where cron errors would show? I've been looking in /var/log/cron but it doesn't seem to show any error messages, just simply which user has run a cron. I've browsed through many threads and everyone else says that /var/log is the place to be.
Then you can comment out the "set -vx" line and spare yourself getting emailed any output if none is required. By default cron emails the user any output it the "MAILTO" variable is set.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
Do you have an empty line at the end of the cron file?
Is this your own cron, or is it /etc/crontab? In the latter case you have to specify a user.
Not running files with .sh extension is nonsense. But better use full paths, and call the program to execute the script explicitely, eq. /bin/bash /path/to/your/script.sh The script file does not have to be executable.
With intervals so short I usually prefer a continuous loop in my script:
Is it showing that it ran in cron at all? You could try appending something like
"> /tmp/generate.log 2>&1"
to your cron entry to catch any errors or messages being output. Also, what others said, always use full path and file names.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.