LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash script cron job (https://www.linuxquestions.org/questions/linux-newbie-8/bash-script-cron-job-4175457463/)

TheQuicken 04-09-2013 04:03 AM

bash script cron job
 
I can't figure out why this script will not run from the crontab -e from a User who owns it.

Runs fine manually via #./listUPDATE

I edited crontab -e to this -

0 0 * * * /home/User/apache/listUPDATE

...nothing happens, will not execute. I also tried editing it to -


0 0 * * * /home/User/apache/listUPDATE > /home/User/cron.log

but nothing is written to the file to give me a clue as to any errors.

Any ideas? Is my syntax wrong? The User executing the job has cron.allow and also has owner/group permissions to script.

Any help would be appreciated, thank you:)

linosaurusroot 04-09-2013 04:28 AM

Is the cron daemon running? Do any other cron jobs work?
Is everything you've shown done as the same non-root user? (The # prompt is usual for root.)
Is anything on this logged in /var/log/messages?

TheQuicken 04-09-2013 04:39 AM

Quote:

Originally Posted by linosaurusroot (Post 4928090)
Is the cron daemon running? Do any other cron jobs work?
Is everything you've shown done as the same non-root user? (The # prompt is usual for root.)
Is anything on this logged in /var/log/messages?


Ahh yes, # oops, meant $ lol.

No there is nothing under /var/log/messages. I haven't tried any other cron jobs but yes the cron daemon is running. Yes everything is run/owned by non-root user.

pan64 04-09-2013 04:42 AM

the most simple test is to write a one-liner like:
echo "here I am" > /tmp/crontabtest
insert it into crontab and you can check if it works
next step is to put it into the beginning of your script.
next to save not only stdout but stderr:
0 0 * * * /home/User/apache/listUPDATE > /home/User/cron.log 2>/home/User/cron2.log
check if those files really can be written...

TheQuicken 04-09-2013 05:02 AM

Quote:

Originally Posted by pan64 (Post 4928099)
the most simple test is to write a one-liner like:
echo "here I am" > /tmp/crontabtest
insert it into crontab and you can check if it works
next step is to put it into the beginning of your script.
next to save not only stdout but stderr:
0 0 * * * /home/User/apache/listUPDATE > /home/User/cron.log 2>/home/User/cron2.log
check if those files really can be written...


Check, these all work.


...wait, what do you mean "insert" into script? Do you mean edit my listUPDATE script with this?

pan64 04-09-2013 06:12 AM

yes, as a check you can try to create a file from the script. That will be a trivial sign, the script has been started (the suggested way is to write its own pid into a file).
Next, you will need to check stderr
also you can insert set -xv into the script to see what's happening

TheQuicken 04-10-2013 03:42 AM

Quote:

Originally Posted by pan64 (Post 4928138)
yes, as a check you can try to create a file from the script. That will be a trivial sign, the script has been started (the suggested way is to write its own pid into a file).
Next, you will need to check stderr
also you can insert set -xv into the script to see what's happening

Inserting "> /home/User/cron.log 2>/home/User/cron2.log" into the script results negative. Same as with inserting set -xv...I'm missing something fundamental I think.

...which would be I'm an idiot. I wasn't entering the script in crontab but rather the path to the script with it's name (listUPDATE).
sooo, problem solved, thank you for letting me waste your time.

pan64 04-10-2013 04:59 AM

"When you have eliminated the impossible, whatever remains, however improbable, must be the truth"


All times are GMT -5. The time now is 06:59 PM.