We have a cron job that sends stuff to another company using SCP. The command look like this:
10 0 * * * ssh USER@LOCAL-SERVER 'scp -q ~/some/dir/* REMOTE_SERVER:/other/dir/' >> ~/log/some.log
This was setup by someone else. Now my problem is that my boss is on the cron mailing list, and despite the ">> ~/log/some.log" cron still sends an email every day, because even if the transfer was successful, it still outputs:
Connection to REMOTE_SERVER 12345 port [tcp/*] succeeded!
And my boss doesn't want to get that email unless an error happens.
The command is really inside a script, which I have omitted to make the make the question simpler. It runs on a RHEL 6 server. But since it's the only line where we talk to REMOTE_SERVER, then it must come from there. And the reason we perform the command on LOCAL-SERVER (Ubuntu 10.04.4 LTS) is because we are on the DB server, which cannot cross the firewall, so we first copy the data to another local server, and upload it from there.
When used without the -q, I also get the following output:
SSH Server supporting SFTP and SCP
I don't want to redirect all stderr output, because I still want to get an email when there is an error.