Is it possible to start a screen session, set up an cronjob, and redirect the cronjob's output to the screen session? Would be great to follow the programm's output ;-)
Greetings....
Is it possible to start a screen session, set up an cronjob, and redirect the cronjob's output to the screen session? Would be great to follow the programm's output ;-)
Greetings....
You could use the
tty
command in that screen to find the path to it's tty (should be something like/dev/pts/12
), and then in crontab redirect all output to that path as if it were a file.Like this:
grawity give a good way to do that but the problem is that each time you restart screen/server the tty will change.
You may do a pipe to the write(1) command like
| write user
. This will send a message to user "user", you just need to have a window opened user this user in screen to see the output butwrite
will add some message before the stdout value.Why not just start screen in the cronjob, then start whatever it is you want to run inside that?
screen -d -m <command to run>
should do the trick.as radius mentioned, there's no sure way of knowing which tty or ttys your screen session will be using at any given moment....or even which of the many pseudo-ttys that might be open in screen is the one that you actually want the output sent to.
your best bet is to redirect the cron job's output (both stdout & stderr) to a file, and then run 'tail -f' or 'tail -F' on it from within screen. that gives you a permanent logfile as well as the ability to watch it in real-time.
alternatively, don't redirect the output at all and just wait for the job to finish - all output will then be mailed to the job's owner.