LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-17-2014, 04:02 AM   #1
INDy2k
LQ Newbie
 
Registered: Oct 2013
Posts: 19

Rep: Reputation: Disabled
issue with crontab job execution


Dear Friends

I'm having some issue when executing script via cron

the script run fine when i run it manually

./scriptname.sh & takes around 10min

but when it executed from cron seems it's not running properly.

We have echo like "job starting at " & "job ending at"
From the logfile I can see that the echo command is executed but
not other commands in between.

starting & ending time is same (or 1sec diff) but actually it should take 10min.

I'm not able to capture terminal message written by this script.

when run manually 'script' command work ( thogh no issue when run manually).

I can't include 'script' command in this script as I'm not able to pass ctrl+D/exit to terminate it.

The devloper who actually write this script ( with TGIT command) couldn't help me much.
(It's a housekeeping job)

Could someone please help me to find the possible cause of this ?
Is there any way to capture the terminal message in log file when the script run which possibly can help
to see errors? ( job run at midnight when no one available at office)


NB: when I run manually first time - it initially showing dir not found - though mentioned path inside script was correct.
Then I create new .sh script by vi & copy same commands again & then it execute in newly created script without any issue.not sure about the reason.
 
Old 04-18-2014, 12:46 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,699

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Are you using absolute paths for the script name in your cron entry?
 
Old 04-19-2014, 12:23 PM   #3
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
se michaelk post but also add set -xvv at the top of your script and push the data to a log file so you can see exactly what is going on.
 
Old 04-22-2014, 10:13 AM   #4
INDy2k
LQ Newbie
 
Registered: Oct 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
Further clarification

$crontab -l
10 01 * * * /scripts/git/repack.sh

where

cat /scripts/git/repack.sh

echo "starting script ... at `date` " >> /scripts/git/log/`date +20%y%m%d`_repack.log
cd /home/gitadmlocal/repositories/ILP/CoreProduct.git
< git command writed by developer -- which is not doing anything when run from cron>
echo "Ending script after running... at `date` " >> /scripts/git/log/`date +20%y%m%d`_repack.log


Housekeeping command working when run the script manually
./repack.sh
 
Old 04-22-2014, 09:02 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,699

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Quote:
cd /home/gitadmlocal/repositories/ILP/CoreProduct.git
Are you trying to run a command or change directories? If the first then remove the cd.

/home/gitadmlocal/repositories/ILP/CoreProduct.git
 
Old 04-23-2014, 03:53 AM   #6
INDy2k
LQ Newbie
 
Registered: Oct 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
Here is the complete script ( repack.sh)

echo "starting script ... at `date` " >> /scripts/git/log/`date +20%y%m%d`_repack.log
cd /home/gitadmlocal/repositories/ILP/CoreProduct.git
git repack -a -d -f --window-memory 200m --max-pack-size 200m --depth 50
echo "Ending script after running... at `date` " >> /scripts/git/log/`date +20%y%m%d`_repack.log


script run fine when run manually by ./repack.sh
 
Old 04-23-2014, 06:28 AM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,699

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
cron has a very limited path environment which is different then your users. Try using the full path to git.
 
Old 04-24-2014, 01:38 AM   #8
INDy2k
LQ Newbie
 
Registered: Oct 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
I've mentioned full path to 'git' command in the script now. This is now working.
Many Thanks for your help.
 
  


Reply



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] Crontab: Cannot see entries, but execution running shivaa Solaris / OpenSolaris 11 02-18-2013 02:38 AM
crontab execution + log argie01 Linux - Software 7 01-03-2013 12:34 PM
[SOLVED] rsync execution issue with crontab - Have given full path to rsync too!! Prabagaran Linux - Server 6 04-15-2011 01:39 AM
create a crontab job by bash script issue xiutuo Linux - Server 4 06-07-2010 10:54 PM
guaranteed scheduled job execution Xstack Programming 4 02-15-2005 10:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:40 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
Open Source Consulting | Domain Registration