Program output in terminal by invoking in cron


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Program output in terminal by invoking in cron
# 1  
Old 01-27-2012
Program output in terminal by invoking in cron

Hi, I have lost a lot of hours by looking for answer but without results.. My problem is that:
I use Debian GNU/Linux and I want to configure cron in order to run rtorrent every day between 24.00 and 09.00. That part I have achieved, but I couldn't forced cron to make it visible on any of my terminals... How should I do that?! I have typed in by "crontab -e":
Code:
"TERM = linux
0 0 * * * /usr/bin/rtorrent my_torrent_files
0 9 * * * pkill rtorrent"

I also have tried:
Code:
"TERM = linux
0 0 * * * tset vt100 && /usr/bin/rtorrent my_torrent_files
0 9 * * * pkill rtorrent"

I'm realy worn out by this single nuisance - I have been configuring my debian box for two days from basic text installation and that part is taking the most of it :/ So, if You could be so kind I would really appreciate that, thanks in advance!

Last edited by methyl; 01-27-2012 at 09:18 AM.. Reason: please use code tags
# 2  
Old 01-27-2012
Put it in script then setup cron with that script.
Script can be run every hour from 24 to 9.

When it starts it will run rtorrent in 24
Then when it runs in 9, it will kill the pid of that rtorrent.

A simple example :

Code:
HOUR=$(date "+%H")
case $HOUR in
24)
/usr/bin/rtorrent my_torrent_files &
RT=$!
;;
09)
## feel free to check the pid before with ps.
kill $RT
;;
esac

# 3  
Old 01-27-2012
Yep, it works pretty well, but still it doesn't puts its output onto whichever /dev/tty*. Maybe there is some kind a command which invokes terminal and can get a program as an argument and show its result in that particular tty. I have tried to redirect its output into tty but to no avail:
"rtorrent >> /dev/tty*"
and
"/dev/tty* < rtorrent"
# 4  
Old 01-27-2012
Use screen in that case.

Since i haven't use it in such manner, will need time to examine a bit.
Regards
Peasant.
# 5  
Old 01-27-2012
There is no terminal context in cron. It is a background process scheduler.

Unless output from a cron job is redirected to a file (or /dev/null) it will by default appear in a unix local mail for the user of the cron.

@Peasant
The value of "date +%H" is range 00-23 . It is never 24.
Also, your script will start many copies of "torrent".


@juru_piotr
I hope that the double quote characters in your post are not actually in your crontab file.
# 6  
Old 01-27-2012
Not it will not start many copies since it will be run one time every hour from cron.
Since it won't ever match 00) more then once, that should't happen.

The 24 is my miss and i apologize for that it should be 00.

Regards
Peasant.
# 7  
Old 01-27-2012
Quote:
Originally Posted by methyl
There is no terminal context in cron. It is a background process scheduler.

Unless output from a cron job is redirected to a file (or /dev/null) it will by default appear in a unix local mail for the user of the cron.
I am aware of that, but that I want to achieve is to force it to do so, either by hook or by crook, for example redirecting this particular program's output to some kind a terminal or (in)directly to my tty*. I think that the whole unix idea is about building magnificent monuments from the tiny blocks Smilie P.S. I assure You, I do not have those both quotes in my crontab - those are just my approaches :P
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print Terminal Output Exactly how it Appears in the Terminal to a New Text File

Hello All, I have a text file containing output from a command that contains lots of escape/control characters that when viewed using vi or view, looks like jibberish. But when viewed using the cat command the output is formatted properly. Is there any way to take the output from the cat... (7 Replies)
Discussion started by: mrm5102
7 Replies

2. Shell Programming and Scripting

Who -u gives different output if run from cron than if run from terminal?

If I run 'who -u' interactively or from a script invoked through bash in a tty on my Ubuntu 12LTS box I get an output like this: testuser pts/0 Dec 9 02:32 . 2163 (host.xx.yy) running the same through cron I get: testuser pts/0 2012-12-09 02:32 00:05 2163... (2 Replies)
Discussion started by: latimer
2 Replies

3. UNIX for Dummies Questions & Answers

invoking non-standard program in linux

I have a program R installed on Ubuntu under /usr/bin/R. I also have a different version installed under /home/user/R. I would like to invoke the locally installed program temporarily. How can I do this automatically by running a script and then switching to the default program? thanks, SM (2 Replies)
Discussion started by: smeme
2 Replies

4. Shell Programming and Scripting

Invoking a program in a loop

In the following script, I wish to invoke a compiled C++ program, consimv4 and pass it some command line arguments through the shell script's command line arguments and variables. But for some reason, when I run the script, I just return to the shell prompt and nothing happens. For the life of me,... (7 Replies)
Discussion started by: msaqib
7 Replies

5. Shell Programming and Scripting

issue invoking shell script using cron, even with proper file permission

I am using tcsh what could possibly be a problem, when using crontab to invoke a shell script. ? The script has the read, write and execute permission to all users. And the script works as expected while executing it in stand-alone mode. Is there a way to trace (like log) what error... (9 Replies)
Discussion started by: vikram3.r
9 Replies

6. Shell Programming and Scripting

cron or terminal ?

Hi all, I need a way to test from within a script if it is running from cron or from terminal. The ways I found till now are: 1) test if $PPID corresponds to the cron daemon 2) see if $TERM has a valid terminal value or "'dumb", in which case it is ran by cron ... but I feel the... (2 Replies)
Discussion started by: pbillast
2 Replies

7. Shell Programming and Scripting

Calling C program from cron results in no output

I can call a C program from the shell and results are outputted as normal. The C program processes some files and spits out a .csv file. If I scheduled it in cron, there is no output. If their a special way to schedule C programs in cron? thanks & regards (1 Reply)
Discussion started by: hazno
1 Replies

8. Shell Programming and Scripting

Problems installing a program in Terminal

Hey First of all: I'm on a Mac. I'm quite new to this, so forgive me if i sound like a newb :-) I wish to install the Deluge BitTorrent client. First of all I installed Macports and made it run smooth. But then I ran into a problem when I should install Deluge. I can post the log, and maybe... (4 Replies)
Discussion started by: Sixmax
4 Replies

9. Programming

terminal device control through a C/C++ program

Hi, I want to fork a new process from a daemon that needs terminal attachment to some ttyN or pts/N device. Here is the code #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <string.h> int main(int... (5 Replies)
Discussion started by: ku@ntum
5 Replies

10. Programming

invoking an Unix script from a C Program

How to invoke an Unix Script from C program? (or) How to invoke another C program from a C program? thanks Karthik (5 Replies)
Discussion started by: fermisoft
5 Replies
Login or Register to Ask a Question