Reputation: 22160
Every time I use the "at" command, I get this message:
warning: commands will be executed using /bin/sh
What is it trying to warn me about? More importantly, how do I turn the warning off?
Upvotes: 18
Views: 9678
Reputation: 33435
If you wish to get around that message, have 'at' run a script that calls a specified environment, be it ksh, bash, csh, zsh, perl, etc.
addition - see the 'at' man page https://web.archive.org/web/20080511234111/http://www.rt.com/man/at.1.html for more information.
at and batch read commands from standard input or a specified file which are to be executed at a later time, using /bin/sh.
Upvotes: 2
Reputation: 46187
Does the warning have any harmful effect aside from being annoying? The man page doesn't mention any way of turning it off, so I don't think you can stop it from being emitted without rebuilding your at from source.
Now, if you want to just not see it, you can use at [time] 2>/dev/null
to send it off to oblivion, but, unfortunately, the at>
prompts are printed to STDERR for some reason (a bug, IMO - they really should go to STDOUT), so they're also hidden by this.
It may be possible to work up some shell plumbing which will eliminate the warning without also eating the prompts, but
at [time] 2>&1 | grep -v warning
) doesn't work andat
to handle it.So, unless it causes actual problems, I'd say you're probably best off just ignoring the warning like the rest of us.
Upvotes: 5
Reputation: 737
The source code for at.c
(from Debian at 3.1.20-3 version) contains an answer:
/* 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");
You can work around it with shell redirection:
% echo "echo blah" | at now+30min 2>&1 | fgrep -v 'warning: commands will be executed using /bin/sh'
job 628 at Fri Mar 8 23:25:00 2019
Or you even create an function for your leisure use (for example for interactive shell in ~/.zshrc
or ~/.profile
):
at() {
/usr/bin/at "$@" 2>&1 | fgrep -v 'warning: commands will be executed using /bin/sh'
}
After that, it will not warn your about with that specific warning (while other warning/errors messages will still reach you)
Upvotes: 4
Reputation: 42618
It serves as a good warning to those of us that don't use bash as our shell, because we we'll forget that a feature that's in our day-to-day shell isn't going to be available when this code is run at the appointed time.
i.e.
username@hostname$ at 23:00
warning: commands will be executed using /bin/sh
at> rm **/*.pyc
at> <EOT>
job 1 at 2008-10-08 23:00
The use of '**' there is perfectly valid zsh, but not /sbin/sh! It's easy to make these mistakes if you're used to using a different shell, and it's your responsibility to remember to do the right thing.
Upvotes: 14