Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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'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.

share|improve this question
up vote 4 down vote accepted

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

share|improve this answer
facepalm You're right. I had it backwards. I was doing "2>&1 /dev/null" instead of "> /dev/null 2>&1" – Aaron C. de Bruyn Mar 1 '11 at 3:33

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.

share|improve this answer

Try wrapping all this in a separate shell script:

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

and edit the cron line to

* * * * * /path/to/your/script &> /dev/null
share|improve this answer

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.