LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 06-12-2007, 06:51 PM   #1
Plastech
Member
 
Registered: Jul 2006
Posts: 63

Rep: Reputation: 15
For cron out loud!!!


Ok, first off, credit to me for the pun in that title....that said...

I have a cron script that runs every hour on the hour which syncs a local folder with my flickr account. The script when called from the command line has a lot of echo/print/whatever statements that generate interesting status updates on the console window. The problem: When I call this script with cron (namely when loaded into IceWM through GDM), nothing is displayed to the user. I know I can email the user, but that's even worse! Is there a simple fix for this?

Thanks,
P
 
Old 06-12-2007, 07:06 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
The cron job is running in the background so it isn't attached to a console. The script probably won't finish running unless you redirect the output.
 
Old 06-12-2007, 07:19 PM   #3
Plastech
Member
 
Registered: Jul 2006
Posts: 63

Original Poster
Rep: Reputation: 15
And how do I do that?
 
Old 06-13-2007, 03:30 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
/home/me/myjob.sh >/home/me/myjob.log 2>&1
 
Old 06-13-2007, 05:35 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Quote:
Originally Posted by chrism01
/home/me/myjob.sh >/home/me/myjob.log 2>&1
That redirects the stderr output to stdout. You could redirect it to a file or to /dev/null.
Also consider rewriting the script so it isn't so noisy. Some commands have a quiet option as well.
 
Old 06-13-2007, 06:22 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
Actually, it re-directs stdout to a file (myjob.log), then also re-directs stderr to the same file ...
 
Old 06-13-2007, 05:40 PM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Quote:
Originally Posted by chrism01
Actually, it re-directs stdout to a file (myjob.log), then also re-directs stderr to the same file ...
Sorry, I just scanned the last part and missed the file.
 
Old 06-14-2007, 08:34 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
No worries; of course you can re-direct stdout & stderr to different files, but it can make it tricky to match up afterwards ...
 
  


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 not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 02:57 AM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 02:50 PM
loud fans coolb Linux - Hardware 9 04-17-2006 04:23 PM
volume too loud moschi Linux - Hardware 6 07-18-2004 01:17 PM
Loud Fan js_530 Linux - Hardware 1 09-20-2003 10:37 PM


All times are GMT -5. The time now is 06:41 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