4

I've currently got a SFTP script that uploads the latest version of a file to a server via SSH which runs on a cron daily. However I always get emails like this (I changed the server to example.com fyi)

/etc/cron.daily/backup:
Connected to example.com.
Connected to example.com.

The relevant part of the script looks like this:

    sftp -o "IdentityFile=~/.ssh/backup" -q backup@example.com > /dev/null << COMMANDS
        cd weekly
    put /srv/backups/daily/$INSTANCE-$(date +%Y%m%d).tgz
    quit
    COMMANDS

It does this twice since it's in a for loop and replaces the $INSTANCE variable with two different names, thus the two Connected to example.com. messages in the cron.

I'd prefer not to print everything to /dev/null since I'd like to get errors in my email. The thing I can think of is by piping to grep and greping for error or failure or something. Is that the only possible alternative?

Any help would be great!

Mooash
  • 43
  • 1
  • 3

2 Answers2

2

I suggest looking at the option for loglevel:

LogLevel

   Gives the verbosity level that is used when logging messages from
   ssh.  The possible values are: QUIET, FATAL, ERROR, INFO, VER-
   BOSE, DEBUG, DEBUG1, DEBUG2 and DEBUG3.  The default is INFO.
   DEBUG and DEBUG1 are equivalent.  DEBUG2 and DEBUG3 each specify
   higher levels of verbose output

I cannot say for sure this will cure your issue 100%, but the default is info (reports connections and failed logins as commond feedback). Moving the log level to FATAL will only show, well FATAL, messages.

Hope this helps you, its in the ssh_config(5) man page.

  • Thanks, doesn't actually fix the issue but I didn't realise you could change the debug level apart from with --verbose! – Mooash Nov 06 '13 at 03:09
0

This option might help :

 -q      Quiet mode: disables the progress meter as well as warning and diagnostic messages from ssh(1).
Mathieu
  • 1,205
  • 2
  • 9
  • 8