LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-09-2013, 04:03 AM   #1
TheQuicken
LQ Newbie
 
Registered: Jan 2013
Distribution: Centos/RedHat/Rhel
Posts: 25

Rep: Reputation: Disabled
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
 
Old 04-09-2013, 04:28 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
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?
 
1 members found this post helpful.
Old 04-09-2013, 04:39 AM   #3
TheQuicken
LQ Newbie
 
Registered: Jan 2013
Distribution: Centos/RedHat/Rhel
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by linosaurusroot View Post
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.

Last edited by TheQuicken; 04-09-2013 at 04:41 AM.
 
Old 04-09-2013, 04:42 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,432

Rep: Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769
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...
 
1 members found this post helpful.
Old 04-09-2013, 05:02 AM   #5
TheQuicken
LQ Newbie
 
Registered: Jan 2013
Distribution: Centos/RedHat/Rhel
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
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?

Last edited by TheQuicken; 04-09-2013 at 05:12 AM.
 
Old 04-09-2013, 06:12 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,432

Rep: Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769
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
 
1 members found this post helpful.
Old 04-10-2013, 03:42 AM   #7
TheQuicken
LQ Newbie
 
Registered: Jan 2013
Distribution: Centos/RedHat/Rhel
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
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.

Last edited by TheQuicken; 04-10-2013 at 04:04 AM.
 
Old 04-10-2013, 04:59 AM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,432

Rep: Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769
"When you have eliminated the impossible, whatever remains, however improbable, must be the truth"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron job did not redirect output from bash script junust Programming 2 07-26-2009 04:30 AM
BASH script for a MySQL cron job - Need help Carlo1973 Linux - Newbie 1 05-20-2009 01:56 AM
HELP - bash script - cron job - not out putting in 132 boyd98 Programming 12 05-01-2007 06:14 PM
How to set up cron job to execute bash script lgmqy2000 Linux - General 4 11-22-2006 04:29 AM
Bash script and cron job rust8y Linux - General 2 07-08-2006 07:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration