3

I've been trying to get the output of a cronjob to show in the terminal and I can't figure it out. Every minute I would like to run the script /usr/games/sl and have it output in the terminal, and I've tried a few different ways, mainly the ones in this post. I can't just write the output to a text file because the command moves across the screen, and it gives gibberish when viewed with tail or nano.

I have two different variations in the crontab file at the moment:

* * * * * /usr/games/sl > /dev/pts/2 2>&1

* * * * * /usr/games/sl > /dev/tty1 2>&1

The second one at least gives me an error, Error opening terminal: unknown. which I think is because I'm using tty1 and not pts/2. I don't really understand how terminals and all of that stuff work yet, so I am stuck at the moment. Does anyone have a suggestion on how I can view the cronjob in real time?

TL;DR Every minute I want the sl command to run on the screen and show the output. I tried with cronjobs and failed.

2 Answers2

0

Have the commands output to a file from crontab and then tail -f the file to monitor the output.

0

Crontasks run in their own shell. You can make the screen do what you want with a simple loop, but it will be dedicated to the task and interrupted by ctrl-c.

while sl;do sleep 1m;done