Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

How do I change the at command shell from sh to bash?

When running at, I recieve the message warning: commands will be executed using /bin/sh:

at 23:33                                                              
warning: commands will be executed using /bin/sh

How can I set the default shell to /bin/bash instead of /bin/sh

share|improve this question
up vote 2 down vote accepted

Looking at man at, it seems like you can't change the shell.

However, you could just launch your commands inside a Bash shell inside at's SH shell, like this:

at 01:23 <<< "bash -c 'notify-send \"running from $SHELL\"'"
share|improve this answer

You can't change the default shell of at, it is hardcoded as /bin/sh in the source.

The source code of at clarifies this, from at.c:

    /* POSIX.2 allows the shell specified by the user's SHELL environment                                                           
       variable, the login shell from the user's password database entry,                                                                
       or /bin/sh to be the command interpreter that processes the at-job.                                                               
       It also alows a warning diagnostic to be printed.  Because of the                                                                
       possible variance, we always output the diagnostic. */

    fprintf(stderr, "warning: commands will be executed using /bin/sh\n");

Implementation, from atd.c:

if (execle("/bin/sh", "sh", (char *) NULL, nenvp) != 0)

The man page conforms accordingly:

at and batch read commands from standard input or a specified file which are to be executed at a later time, using /bin/sh.

That leaves you to recompile your own copy as the only solution to meet your need.

share|improve this answer
    
Well... he could also symlink bash to /bin/xy (or any 7-character or shorter absolute pathname), and manually edit the correct /bin/sh string in the compiled at binary to be the new path (not really recommended to anyone who isn't comfortable hex-editing binaries, but possible). – mtraceur 1 hour ago

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.