1

I'm baffled as to why this isn't working.

I've tried redirecting STDOUT and STDERR using "&>" and also "2>&1" and neither seems to work. I still get e-mailed by this cron job (every minute!) with smbclient complaining that there are no files in the share.

* * * * * smbclient //scanner/scan-import secretpass -U administrator -c "prompt; mget *; del *" &> /dev/null

For the curious: A client has an old and expensive scanner that scans multiple documents at high speed--but the software has no way to configure the save location. They don't want the documents saved directly on the old XP workstation, so I've shared out the save location and use this cron job to automatically pull the documents over to their linux server.

Aaron C. de Bruyn
  • 578
  • 10
  • 28

3 Answers3

5

Bash supports redirecting stdout and stdin together using &>, but sh does not. Cron used the Bourne shell (sh) rather than Bash. Use >/dev/null 2>&1 instead.

Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
4

I don't think you need the first "&" do you? Just "> /dev/null 2>&1";

Devin Ceartas
  • 1,458
  • 9
  • 12
2

Try wrapping all this in a separate shell script:

#!/bin/bash
smbclient //scanner/scan-import secretpass -U administrator \ 
      -c "prompt; mget *; del *" 

and edit the cron line to

* * * * * /path/to/your/script &> /dev/null
Sven
  • 97,248
  • 13
  • 177
  • 225