Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using scp for backuping data. When I get the cron output(using crontab file for cron operations) with mail, I do not get any output. The scp operation is done succesfully.

So, in the terminal I get for example: test.file 100% 1489KB 1.2MB/s 00:00

But in the cron output, I do not get the output of the command.

Does someone know how to do this or which other way do you use to get information about the command?


share|improve this question
up vote 0 down vote accepted

Generally cron is good about sending out any terminal output from it's jobs to the email account for the user on the box it was run under. Sometimes people setup cron jobs with the output specifically redirected or suppressed so that this does not happen. Make sure that this is not the case. If you like you can post your crontab line here and we can tell you.

Also, in order to get the email, you either need to check the mailbox of the user on the box the job runs as, or set it up to route somewhere else. You can usually do this with the system email alias file often in /etc/mail/aliases. For example my boxes all have a line that says "root:" so that I receive the emails for all cron jobs run as root.

Edit 1: Apparently scp detects when it is being run from a terminal and changes it's output to silent when it is not. Adding a -v should over-ride this behavior.

Edit 2, alternate solution: I highly recommend using rsync instead of scp for this kind of operation. It is designed with this kind of repeated synchronization in mind, handles cases like being able to transfer only updated parts of file or directories etc. It's output is also more suited to use in cron. You can still use ssh for the transport and authentication: rsync -e ssh -v source_file_or_dir user@remotehost:dest_file_or_dir. Adding -a for archive mode to synchronize recursive directories and match file properties and --delete to include deleting remote files not found locally are common options. Be sure to end both the source ad dest arguments with a trailing slash (/) if you are synchronizing directories.

share|improve this answer
I just have a simple scp command: "scp -r /dir user@server/dir" (without /dev/null, ...). I get cron email. I get the output of the "echo" command and other commands. – user28362 Oct 5 '10 at 7:30
Hum. My guess is scp is detecting that it is not being run from a terminal and automatically adding a silent option to itself. You can over-ride this by adding a -v. Also, I highly recommend switching to rsync for this. You can still use ssh as the transport, but it has much better handling for synchronization including partial file updates, directory matching, etc. – Caleb Oct 5 '10 at 7:35
verbose does give debug info about ssh connection etc (too much info). I'll check rsync. – user28362 Oct 5 '10 at 7:46
Given the rough nature of the command you showed above, you'll need something like this: rsync -ave ssh /dir/ user@server:/dir/ Note the trailing slashes are important. You can also add a --delete if you want deleted items in the local dir to also be deleted remotely. – Caleb Oct 5 '10 at 7:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.