LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 05-22-2009, 03:44 AM   #1
pranavojha
Member
 
Registered: Feb 2006
Location: Bangalore, India
Distribution: Fedora Core 3
Posts: 67

Rep: Reputation: 15
Crontab doesn't give the output of the file it runs in terminal


I have scheduled a shell script to run at a particular time of day using 'crontab'.
Code:
# crontab -l
30 22 * * 5 /bin/su root -c "/myscript.sh"  
#
However, the echo commands output are not displayed on the terminal window when the script executes. I tried setting the crontab in the following manner,
Code:
# crontab -l
30 22 * * 5 /bin/su root -c "/myscript.sh"> /dev/stdout  
#
.

But still I do not see the output on the screen. How can get the output of a script run by 'cron' on terminal screen ?

Last edited by pranavojha; 05-22-2009 at 03:46 AM.
 
Old 05-23-2009, 11:50 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Slackware current
Posts: 8,460

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
Cron normally sends you mail if a cron task generated any output (this
should include error messages).
You could redirect the output to a logfile.
 
Old 05-23-2009, 12:11 PM   #3
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: OpenSUSE 12.1 CentOS 6.2
Posts: 9,003

Rep: Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349
To get the output in a terminal, you have to explicitly open it from the cron job and launch the script as a terminal command. Using KDE I can do something like:
Code:
10 19 * * * env DISPLAY=:0.0 konsole --noclose -e echo hello world
note that you have to set the DISPLAY environment variable, otherwise cron does not know where to open a new terminal. Furtehrmore the user to which the crontab belongs, must have an X session open (take in mind you cannot connect to the X display of another user, since usually you don't have the right permissions).

Finally, you have to find a way to keep the terminal open after the command execution. In konsole, as you can see from my example, there is a --noclose option. You have to find the trick if you use another terminal.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange output log of crontab kuangchen Linux - Newbie 1 05-30-2008 04:13 AM
crontab runs and stops in middle of process. Strange! Micro420 Linux - General 2 03-28-2007 02:46 AM
Redirect terminal output to file AND terminal shan Linux - General 3 09-29-2006 08:36 AM
How to direct output both log file and to terminal... freebies Linux - General 1 02-25-2005 06:32 AM
C++ prorgam runs OK from command line, but failed from crontab vgolden Linux - Software 2 01-21-2005 11:00 AM


All times are GMT -5. The time now is 08:54 PM.

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
Open Source Consulting | Domain Registration