Crontab doesn't give the output of the file it runs in terminal
I have scheduled a shell script to run at a particular time of day using 'crontab'.
Code:
# crontab -l Code:
# crontab -l But still I do not see the output on the screen. How can get the output of a script run by 'cron' on terminal screen ? |
Cron normally sends you mail if a cron task generated any output (this
should include error messages). You could redirect the output to a logfile. |
To get the output in a terminal, you have to explicitly open it from the cron job and launch the script as a terminal command. Using KDE I can do something like:
Code:
10 19 * * * env DISPLAY=:0.0 konsole --noclose -e echo hello world Finally, you have to find a way to keep the terminal open after the command execution. In konsole, as you can see from my example, there is a --noclose option. You have to find the trick if you use another terminal. |
colucix,
Thanks for that answer. An update for any debian users (I'm using Mint15 but Ubuntu etc should be the same). I am using rdiffbackup so call a script that drives it. My command line is: Code:
04 07 * * * env DISPLAY=:0.0 gnome-terminal -e /home/of user/.rdiffbackup With gnome-terminal you can choose behaviour of the terminal when the command finishes. In my case I wanted the terminal to disappear if all backups complete successfully so I didn't. Instead I use the read command after an error to pause the terminal, awaiting user input. A note for any rdiffbackup users having issues with cron. Cron has a very limited user environment compared with your terminal so you may have to fill in some missing variables for the SSH to work for rdiffbackup. In my case I needed to fill in SSH_AGENT_PID and SSH_AUTH_SOCK - the code is for the fish shell ... substituted " for the brackets around the command if you're using bash. The second assumes that the folder *keyring-* and associated file *ssh* is within /run - if its not then find out where your distro hides it and change it (the originator of this idea was searching /tmp for it). Code:
set -x SSH_AGENT_PID (ps axww | grep -v grep | grep ssh-agent | grep -o -e [0-9][0-9][0-9][0-9]) |
All times are GMT -5. The time now is 04:51 AM. |