LinuxQuestions.org
Review your favorite Linux distribution.
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 11-24-2014, 11:31 PM   #1
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Rep: Reputation: 16
Question Cron runs only manual on Centos


Hi

I use a cron on Centos to run a backup script:

Code:
5 6 * * * /script/backup.sh
So at 06:05 the cron should start...

Checking by command "date" i have the same time and date with the server and ll done as root on the server....

The cron is not running and from the logs i can't see any related message:

Code:
Nov 25 05:25:01 server CROND[29894]: (root) CMD (/usr/local/rtm/bin/rtm 10 > /dev/null 2> /dev/null)
Nov 25 05:26:01 server CROND[29964]: (root) CMD (/usr/local/rtm/bin/rtm 10 > /dev/null 2> /dev/null)
Nov 25 05:27:01 server CROND[30016]: (nodequery) CMD (bash /etc/nodequery/nq-agent.sh > /etc/nodequery/nq-cron.log 2>&1)
Nov 25 05:27:01 server CROND[30015]: (root) CMD (/usr/local/rtm/bin/rtm 10 > /dev/null 2> /dev/null)
Nov 25 05:27:41 server crontab[30674]: (root) BEGIN EDIT (root)
Nov 25 05:27:47 server crontab[30674]: (root) END EDIT (root)
Nov 25 05:28:01 server CROND[30683]: (root) CMD (/usr/local/rtm/bin/rtm 10 > /dev/null 2> /dev/null)
Nov 25 05:29:01 server CROND[30733]: (root) CMD (/usr/local/rtm/bin/rtm 10 > /dev/null 2> /dev/null)
No logs at 06:05 at all....

When i try to run it using:

cd /script
./backup.sh

Is running and all are great without any errors at all...

Any ideas?

Thanks
 
Old 11-25-2014, 01:16 AM   #2
ilesterg
Member
 
Registered: Jul 2012
Distribution: Arch, Debian, and CentOS/RHEL
Posts: 541

Rep: Reputation: 56
Count the number of ALL processes (which kicked off using cron) in ps which are running currently. I had this issue before when there were 100 process instances of 1 other script (runs every 10 minutes), which prevented ALL OTHER cron jobs to kick off. Maybe you also encounter this? though mine was in AIX.
 
Old 11-25-2014, 03:59 AM   #3
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,576

Rep: Reputation: 938Reputation: 938Reputation: 938Reputation: 938Reputation: 938Reputation: 938Reputation: 938Reputation: 938
Just because your script runs fine when you manually run it does NOT mean it will run correctly as a cron job.

When a job is run from the cron it does not necessarily pick up the whole path or shell environment variables that the user shell session would.

If your script is a bash script then try set -x at the start of your script and redirect the output in the cron job:

Code:
5 6 * * * /script/backup.sh > /script/backup.log
That may give you some clues.
 
Old 11-25-2014, 01:01 PM   #4
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Original Poster
Rep: Reputation: 16
Do you mean chown +x ? If yes then i done it already....

If not how can i do this -x ?

The crazy thing is taht i have the exact same script and path to aother server and with the same cron command it runs great ....

Thanks
 
Old 11-25-2014, 01:08 PM   #5
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,576

Rep: Reputation: 938Reputation: 938Reputation: 938Reputation: 938Reputation: 938Reputation: 938Reputation: 938Reputation: 938
Quote:
Originally Posted by ASTRAPI View Post
Do you mean chown +x ?
No, if I had meant chown +x (which is pointless, did you mean chmod +x?) then I would have said so.

Add set -x as a separate line in your script, after your #!/blah/blah line and it will cause your script to show you each line as its executing, essential for debugging/troubleshooting.
 
Old 11-25-2014, 05:03 PM   #6
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Original Poster
Rep: Reputation: 16
Now it works thanks

Last edited by ASTRAPI; 11-26-2014 at 07:55 PM.
 
  


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
[SOLVED] Cron files in /etc/cron.d/ not running - CentOS 6.5 mcresist Linux - Server 7 07-05-2017 09:50 AM
[SOLVED] [cron] Root cron ib centos 6.3 doesn't work/ killout Linux - Newbie 2 12-17-2012 02:26 PM
Unexpected results: Difference in Perl Script Behavior between manual and cron runs EnderX Programming 3 12-11-2010 12:42 AM
How to tell if clamav cron runs cuco76 Linux - Software 2 10-12-2007 04:21 PM
Why Does One Cron Job Runs Twice? cpope67 Programming 4 11-16-2004 07:09 AM

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

All times are GMT -5. The time now is 03:57 PM.

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