[PLUG] bash vs dash and the "at" command

chris (fool) mccraw gently at gmail.com
Mon Oct 25 18:53:52 UTC 2010


On Mon, Oct 25, 2010 at 11:27, frankhunt <fh-linux at frankhunt.com> wrote:
> Does the "at" scheduler use bash or dash?

mine (ubuntu 10.4 still) uses /bin/sh as documented in the first line
of the at(1) man page.  on my system, /bin/sh is linked to dash rather
than bash.  i believe there have been other conversations on here
about relinking /bin/sh to bash and how it breaks things, so that's
probably not a good fix.  plus, when run as 'sh', bash behaves like
its slower older brother posix bourne shell--see
http://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html.


> Ideas??

a fine point of at(1) job submission that i just discovered from the
same man page, is that if you submit a file, it is treated as a list
of commands, run via /bin/sh.  if you submit from standard in, it will
instead just run the command, which if it is a script will obey your
opening shebang line.  i just tested that and it works fine (run: at
now +4 hours, type in the path to your script, hit control d, or just
"echo /path/to/script | at now +4 hours).  you can put the calculated
time specification into the command line that runs at, rather than in
the script itself, maybe?  i'd use expr(1) with date(1) to do it
rather than the shell builtin 'let'.  you could use date +%s to grab
number of seconds since the epoch as a source of a number that won't
be the same twice (unless you execute your script twice in one
second).

i guess another workaround is to submit a file that just has one line
that runs the other script (with the bash-specific shell functions in,
starting with #!/bin/bash), if you really must submit a file rather
than using stdin.

luck++;



More information about the PLUG mailing list