"stdin: is not a tty" from cronjob

Asked
Active3 hr before
Viewed126 times

6 Answers

90%

I'm getting the following mail every time I execute a specific cronjob. The called script runs fine when I'm calling it directly and even from cron. So the message I get is not an actual error, since the script does exactly what it is supposed to do.,It happens because ssh does not allocate a terminal when called with a command as a parameter (one should use -t option for ssh to force the terminal allocation in this case).,This warning message is printed by bash -l. The -l (--login) options asks bash to start the login shell, e.g. the one which is usually started when you enter your password. In this case bash expects its stdin to be a real terminal (e.g. the isatty(0) call should return 1), and it's not true if it is run by cron—hence this warning.,If you run into this problem check if you are getting all the environment variables set as you expect. Thanks to Cyrus for putting me to the right direction.

Another easy way to reproduce this warning, and the very common one, is to run this command via ssh:

$ ssh user @example.com 'bash -l -c "echo test"'
Password:
   stdin: is not a tty
test
load more v
88%

Connect and share knowledge within a single location that is structured and easy to search., Help Center Detailed answers to any questions you might have , What was the affiliation of the "Reverend Mother" who assisted with Jessica's spice agony? , Why do pilots slowly give the plane more thrust during takeoff?

Change your .profile to

# Bash doesn 't load its interactive initialization file if it'
s invoked as
# a login shell, so do it manually.
case $ - in
   *
   i * ) if [-n "$BASH"];
then.~/.bashrc;; fi
esac
72%

I'm seeing this after upgrading from 2016.3 to 2017.7 on Ubuntu 14.04.,Here is the relevant part of the log:,The problem only seems to trigger when executing the command as root:,Execute a Salt command involving the cron module, such as:

# salt - call cron.ls root
stdin: is not a tty
local:
   -- -- -- -- --
crons:
   |
   _
   -- -- -- -- --
cmd:
   /usr/local / bin
/*redacted*
          comment:
          commented:
              False
          daymonth:
              *
          dayweek:
              *
          hour:
              *
          identifier:
              *redacted*
          minute:
              */
15
month:
   *
   |
   _
   -- -- -- -- --
cmd:
   /usr/local / bin
/*redacted*
          comment:
          commented:
              False
          daymonth:
              *
          dayweek:
              *
          hour:
              *
          identifier:
              *redacted*
          minute:
              */
9
month:
   *
   env:
   pre:
   special:
load more v
65%

I'm using OMV since a year or so and I'm totally satisfied with it. After the last update I get an email notification after a cron job is startet saying "stdin: is not a tty".,I also got that email after the update to the latest omv 3.0.95:,Can we not fix this for everyone with a patch update?,WIth the modification It works !

if ["$BASH"];
then
if [-f~/.bashrc ]; then
   .~/.bashrc
   fi
   fi

   mesg n
load more v
75%

Diese geschieht über Crontab mit folgender Syntax:,Wir haben ein Script, dass regelmäßig unsere Server updatet:,Ich muss aber diesen Aufruf im Script haben.,Ich blocke im Script schon von vornherein einiges, dass irrelevant ist mit dem Kommando:

1
2
load more v
40%

Edit/Open your cron jobs, enter: $ crontab -e Append string >/dev/null 2>&1 to stop mail alert:,great it worked! >/dev/null 2>&1,Thanks for the tip, works great to disable cron emails.,Running crontab (cron jobs) Every 10 Minutes

Edit/Open your cron jobs, enter:
$ crontab -e
Append string >/dev/null 2>&1 to stop mail alert:

0 1 5 10 * /path/to / script.sh > /dev/null
2 > & 1

OR

0 1 5 10 * /path/to / script.sh > /dev/null

OR

0 * * * * /path/to / command arg1 > /dev/null
2 > & 1 || true
# # send email to backup team #
MAILTO = "backup.admin@domain-here"
@daily / scripts / backup.sh

# # send email to RAID / storage / san / nas admin # #
MAILTO = "storage.admin@domain-here" *
   45 * * * /scripts/test - raid - array.sh

Another example:

# # NO EMAIL # #
@weekly / scripts / containers - backup > /dev/null
2 > & 1

# # Send email # #
MAILTO = "sysadmin@corp2.domain-here"
@daily / scripts / test - raid - array.sh

# # Disable email alert # #
MAILTO = ""
@monthly / path / to / script / logs.sh > /var/log / monthly.log
load more v

Other "undefined-undefined" queries related to ""stdin: is not a tty" from cronjob"