LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 07-01-2011, 02:05 PM   #1
dahweeds
LQ Newbie
 
Registered: Nov 2008
Posts: 24

Rep: Reputation: 0
BASH Script will not get use result of command when run as cron job


Hi.
I am frustrated by running a script on the Fedora 14 computer as a cron job.

I paste the code:
Code:
#!/bin/bash

#a backup script to copy data from sda to sdc

ROOTVOL=`blkid -U ea210a08-6212-4dc8-be1c-23fce3b965bc`

HOMEVOL=`blkid -U 91e3df85-9842-425d-b6b2-1faa5d5e17b2`

BOOTVOL=$(blkid -U 0f979f2a-6852-4793-bf5e-91878686b845)

logger ADMIN: Executing backup-svn

logger using blkid ea210a08-6212-4dc8-be1c-23fce3b965bc as $ROOTVOL
logger using blkid 91e3df85-9842-425d-b6b2-1faa5d5e17b2 as $HOMEVOL
logger "using blkid 0f979f2a-6852-4793-bf5e-91878686b845 as $BOOTVOL"

exit 1
So when I run this as root, for example:
Code:
# /root/myscript
the result is what I expect:
Code:
Jul  1 13:41:16 svn root: ADMIN: Executing backup-svn
Jul  1 13:41:16 svn root: using blkid ea210a08-6212-4dc8-be1c-23fce3b965bc as  /dev/mapper/vg_svn_backup-lv_root
Jul  1 13:41:16 svn root: using blkid 91e3df85-9842-425d-b6b2-1faa5d5e17b2 as  /dev/mapper/vg_svn_backup-Logical_Volume_01
Jul  1 13:41:16 svn root: using blkid 0f979f2a-6852-4793-bf5e-91878686b845 as /dev/sdb1
So, I set it to run as a cron job but it does not correctly grab the device name from the blkid command. the result is:
Code:
Jul  1 13:41:16 svn root: ADMIN: Executing backup-svn
Jul  1 13:41:16 svn root: using blkid ea210a08-6212-4dc8-be1c-23fce3b965bc as  
Jul  1 13:41:16 svn root: using blkid 91e3df85-9842-425d-b6b2-1faa5d5e17b2 as  
Jul  1 13:41:16 svn root: using blkid 0f979f2a-6852-4793-bf5e-91878686b845 as
I tried different strategies of quotes and braces and parenthesis but none seems to work when the cron job runs. The block name variables are empty.

Can anyone pinpoint what I have missing when it goes by cron?
 
Old 07-01-2011, 03:19 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,565

Rep: Reputation: 659Reputation: 659Reputation: 659Reputation: 659Reputation: 659Reputation: 659
This type of failure is a common problem in cron jobs. The blkid command is commonly located in /sbin, which is not likely to be in a cron job's PATH. Try using the full path to blkid.
 
1 members found this post helpful.
Old 07-01-2011, 04:02 PM   #3
dahweeds
LQ Newbie
 
Registered: Nov 2008
Posts: 24

Original Poster
Rep: Reputation: 0
wow

Quote:
Originally Posted by rknichols View Post
This type of failure is a common problem in cron jobs. The blkid command is commonly located in /sbin, which is not likely to be in a cron job's PATH. Try using the full path to blkid.
Wow.
being the noob, I never would have thought of that.

thank you.
I worked 100%

Thank you for your help

Last edited by dahweeds; 07-01-2011 at 04:32 PM. Reason: It worked
 
Old 07-01-2011, 08:01 PM   #4
corp769
Guru
 
Registered: Apr 2005
Posts: 5,814

Rep: Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001
Quote:
Originally Posted by dahweeds View Post
Wow.
being the noob, I never would have thought of that.

thank you.
I worked 100%

Thank you for your help
Hello,

Since you have solved your problem, could you please mark your thread as [SOLVED] so the rest of us know that your issue is solved? Thanks!

Cheers,

Josh
 
  


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] Partial list with ls-l in bash script run in cron but full list run from command line redgshost Linux - General 29 01-16-2011 01:14 PM
[SOLVED] BASH: Add cron job to run hourly worm5252 Programming 9 03-26-2010 11:36 AM
Bash script run via cron not executing MYSQL command mackstar Linux - Server 4 04-23-2009 06:01 AM
script does not run in cron job kashyapvirgo Linux - General 8 03-20-2007 11:55 AM
Bash script and cron job rust8y Linux - General 2 07-08-2006 08:45 AM


All times are GMT -5. The time now is 01:45 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration