Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 recently switched from 2>&1 >> to &>>

Is there a way to have at use /bin/bash as the shell? By default it uses /bin/sh and the man page gives no indication how anything else can be used. Even in a crontab one can use SHELL=/bin/bash

The main problem this has been causing me is that in:

echo "do-smth.sh &>> logfile" | at now + 8 hours

instead of appending both stdout and stderr to my logfile, they have been getting lost altogether, not even getting emailed.

This workaround didn't work, citing unexpected redirection:

echo "bash <<< \"do-smth.sh &>> logfile\"" | at now + 8 hours

I use Linux, Ubuntu 11.10 flavor, which shouldn't matter.

share|improve this question

migrated from stackoverflow.com Feb 1 '12 at 15:19

This question came from our site for professional and enthusiast programmers.

It seems for now it can't be changed because the at daemon hardwires /bin/sh somewhere. My workarounds to call bash complicate and make for very confusing double/triple quote escaping. – Marcos Feb 25 '12 at 14:27

Your problem is that the way your command is written, sh is trying to handle the herestring redirection, and (being linked to dash, not bash, in Ubuntu) it doesn't have the <<< operator. You probably want this:

echo 'bash -c "do-smth.sh &>>logfile"' | at now + 8 hours
share|improve this answer

For the record here's what I'm getting by with, in one use case. Notice how badly it's obfuscated due to unavoidable single- or double-quote escaping:

      pidof -x pngcrush || at now <<< 'time nice bash -c '\''
(for f in $(find orderlog/ -mtime -1 -name \*.png); 
do convert -trim +repage -colors 64 -depth 6 -verbose $f $f.tmp; 
ls -lFa $f*; 
touch -r $f $f.tmp && mv -f $f.tmp $f; 
time find orderlog/ -mtime -3 -name \*.png -execdir  pngcrush -bit_depth 8 -d ~/tmp -oldtimestamp {} + ; 
mv -fv ~/tmp/*.png orderlog/; 
timeout 1h time find orderlog/ -mtime -2  \( -name \*.png -o -name \*.gif \) -execdir  optipng -keep -preserve -o6 -v  {} + ; 
rm -vf orderlog/*.png.{bak,tmp} ) &> orderlog/imgshrink.log'\'' ' 

Newlines added only here for readability.

Since it's inside a script it's grown to where I should turn it into a here-document for at to read, except I am afraid of breaking the (non)parse for bash.

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.