Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

3 Answers

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
1  
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
add comment

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
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

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.