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 12-16-2007, 04:54 AM   #1
hocheetiong
Member
 
Registered: Jul 2007
Location: Penang , Malaysia.
Distribution: red hat linux
Posts: 133

Rep: Reputation: 15
Smile using crontab how to show on tty1 or from GUI "xterm".


hi, I am in RHEL5, i know how to setup cron job, but i dont know how to run the one of the cron job on tty1 or on GUI x-term. Example: i want the cron job to list all files on root, ok i first create a file name "cron_ls", than i edit it by vi editor as below:

****1 ls -al

than i save this file "cron_ls" at root.ok now i want to add this job to crontab. command:

# crontab cron_ls

ok. i have success run this cron job, but if i want this cron job run on my screen "tty1" or on my GUI Gnome terminal, like normal went i operate my RHEL5, example: i want to run command to list all my root file, than i just direct go to tty1 than issue the command ls -al than will show the result on my screen "tty1", or i using GUI,than open gnome terminal than do the same thing will also display the result on mu gnome terminal. Now i want the cron job also same show on my "tty1" screen,or on my GUI gnome terminal.

thank you.
 
Old 12-16-2007, 05:31 AM   #2
aus9
LQ Guru
 
Registered: Oct 2003
Distribution: MX
Posts: 5,132

Rep: Reputation: Disabled
if you mean /etc/cron.daily/script then open your shell and type commands

su
/etc/cron.daily/script...change script to whatever it is called
 
Old 12-16-2007, 06:09 AM   #3
hocheetiong
Member
 
Registered: Jul 2007
Location: Penang , Malaysia.
Distribution: red hat linux
Posts: 133

Original Poster
Rep: Reputation: 15
Smile sorry i am not mean like that.

sorry i am not mean like that, what i am said is, i want my cron job went it running will totally same like what i am sit infront my system and issue the command the running and the display & output. example: i am infront my system i open tty1 or open GUI gnome terminal to issue command ls -al than my monitor screen will come out the result, what i want is my cron job also totally like that.

Thank you.
 
Old 12-16-2007, 06:05 PM   #4
aus9
LQ Guru
 
Registered: Oct 2003
Distribution: MX
Posts: 5,132

Rep: Reputation: Disabled
I understand....lets keep your example of ls.....with your real command remember you need to tell cron the full pathway

eg /usr/bin/X or /bin/y or /sbin/z ok?

copy and paste the following into a text editor excluding the dash line

---------------------------------------------

#!/bin/sh

( date; cd / && /bin/ls -al) \
| /bin/mail -s "list daily run on `uname -n`" root

exit 0

--------------------------------------------------------------

2) with root powers save this file as

/etc/cron.daily/list

then change permissions to make it root power executable. Its easy with Konqueror KDE file manager but if you have to use command line its

chmod 700 /etc/cron.daily/list

confirm you have correct with
ls -al /etc/cron.daily/list
reply must be ......-rwx------

3) test it before you turn off computer with

/etc/cron.daily/list
and a second later run new command

mail....to check its output....the cronjob will mail you each day the command output.
 
Old 12-16-2007, 06:44 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
You can send output to another terminal by redirecting to the correct /dev/ttyN or /dev/pts/N, where N is the identifier of the terminal or pseudo-terminal in which you want to print output. Suppose you have /dev/pts/1 open: you can do something like
Code:
39 0 * * * /bin/ls -al > /dev/pts/1
The problem is to determine which terminal is open/available. For example, you can write a little script which parses the output of the who command and extract the relevant piece of information. Once the script has found all the available terminals, it will try to send output to all of them in sequence until the ls command exit successfully.
 
  


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
"Minicom -s" works, but it always show "Offline", then cannot communicate with others reflecter_chen Linux - Hardware 8 05-14-2016 03:05 PM
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 02:03 AM
Make "ls" command show colors without "--color=always" switch SharpyWarpy Linux - General 4 07-17-2007 12:00 AM
2.4 kernel w/ devfs "/dev/tty1-8: No such file or directory" hedpe Linux - Software 0 05-19-2006 06:37 PM
repeated message (tty1): ASSERT: "i <= nodes" in /usr/lib/qt-3.1.2/include/qvaluelist megahard Linux - General 4 01-17-2006 11:59 PM


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