1
vote
1answer
130 views

Why does redirection in crontab result in a zero byte file?

System: Xubuntu 13.10 When I have this crontab entry */5 * * * * cat /home/dbk/.bash_aliases &> /home/dbk/Desktop/junk junk has a byte size of 0. Running $ cat /home/dbk/.bash_aliases ...
3
votes
2answers
195 views

Bash if script is called from terminal echo stdout to terminal, if from cron do not echo output

I would like to have a service watchdog script echo the status to the screen if called like ./watchdog.sh but if it is run by cron, there is no need to echo output. What is the proper method? Where ...
6
votes
3answers
5k views

How do I completely silence a cronjob to /dev/null/?

On my Ubuntu-Desktop and on my debian-server I have a script which needs to be executed each minute (a script that calls the minute-tic of my space online browsergame). The problem is that on ...
3
votes
1answer
228 views

Running time command with cron

So I have a crontab that have this line: 30 16 * * * (time sysbench --test=cpu --cpu-max-prime=20000 run) 2>> ~/cpu.out I use this because time output goes by default to stderr and I want to ...
8
votes
1answer
13k 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
944 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
2k 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
2k 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 ...