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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-16-2007, 04:54 AM
|
#1
|
Member
Registered: Jul 2007
Location: Penang , Malaysia.
Distribution: red hat linux
Posts: 133
Rep:
|
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.
|
|
|
12-16-2007, 05:31 AM
|
#2
|
LQ 5k Club
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842
Rep:
|
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
|
|
|
12-16-2007, 06:09 AM
|
#3
|
Member
Registered: Jul 2007
Location: Penang , Malaysia.
Distribution: red hat linux
Posts: 133
Original Poster
Rep:
|
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.
|
|
|
12-16-2007, 06:05 PM
|
#4
|
LQ 5k Club
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842
Rep:
|
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.
|
|
|
12-16-2007, 06:44 PM
|
#5
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
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.
|
|
|
All times are GMT -5. The time now is 02:46 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|