Tagged Questions
3
votes
1answer
1k views
How to redirect output to a file from within cron?
I have a backup script which I need to run at a particular time of a day so I am using cron for this task and from within cron am also trying to redirect the output of backup script to a logfile.
...
8
votes
1answer
613 views
Suppress output unless non-zero exit code
What's the best way to suppress output (stdout and stderr) unless the program exits with a non-zero code? I'm thinking:
quiet_success()
{
file=/tmp/suppressed
if ! ( "$@" > "$file" ...
3
votes
1answer
822 views
Why does sftp hide the log from stdout?
I have a script a.sh, which has an sftp command:
echo "Starting to sftp..."
sftp xxx@xxx.xxx.xxx.xx << END_SCRIPT
ls
mput *.csv.gz
bye
END_SCRIPT
echo "Sftp successfully."
If I run it ...
6
votes
2answers
888 views
Logging ALL stderr output of crontab to file
For example, I can log stderr of one script in this way:
* * * * * run_script.sh > /var/log.txt 2>&1
But I want to log stderr of all scripts in my crontab. I can append > /var/log.txt ...