View previous topic :: View next topic |
Author |
Message |
toralf Developer


Joined: 01 Feb 2004 Posts: 3943 Location: Hamburg
|
Posted: Sat Feb 18, 2017 5:37 pm Post subject: [solved]after reboot:/bin/sh: bad interpreter: Permission d |
|
|
I do wonder about getting this error message from cron via email at a hardened Gentoo server (only once immediately after reboot) : Code: | /bin/sh: /home/tinderbox/tb/bin/logwatch.sh: /bin/sh: bad interpreter: Permission denied | The appropriate cron entry is: Code: | $ crontab -l
*/1 * * * * ~/tb/bin/logwatch.sh | and the script itself is just sth like. Code: | $ cat /home/tinderbox/tb/bin/logwatch.sh
#!/bin/sh
#
#set -x
<watch log files and ring a bell if they are non-empty>
|
Update:PEBKAC, it scaused by GrSec trusted path execution - I forgot to run appropriate sysctl calls early enough
Last edited by toralf on Fri Apr 07, 2017 9:35 am; edited 1 time in total |
|
Back to top |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sat Feb 18, 2017 6:30 pm Post subject: |
|
|
toralf ...
please do not provide pseudo code, if logwatch.sh calls anything that isn't available, or +x, then this can result in a 'bad interpreter' error, you can also get this if the script has windows line endings, if the script is on a filesystem with 'noexec' set, or /home is NFS. I would check/provide the following:
Code: | # ls -l /home/tinderbox/tb/bin/logwatch.sh
# cat -vET /home/tinderbox/tb/bin/logwatch.sh
# mount |
It may be none of the above, so you might try changing the crontab to:
Code: | */1 * * * * sh /home/tinderbox/tb/bin/logwatch.sh |
best ... khay |
|
Back to top |
|
 |
toralf Developer


Joined: 01 Feb 2004 Posts: 3943 Location: Hamburg
|
Posted: Sat Feb 18, 2017 7:04 pm Post subject: |
|
|
Well, Code: | tinderbox@mr-fox ~ $ ls -l /home/tinderbox/tb/bin/logwatch.sh
-r-xrwx--- 1 tinderbox tinderbox 535 Feb 17 20:24 /home/tinderbox/tb/bin/logwatch.sh
tinderbox@mr-fox ~ $ cat -vET /home/tinderbox/tb/bin/logwatch.sh
#!/bin/sh$
#$
#set -x$
$
mailto="tinderbox@zwiebeltoralf.de"$
$
if [[ -s ~/nohup.out ]]; then$
(ls -l ~/nohup.out; head -n 500 ~/nohup.out) | timeout 120 mail -s "nohup.out is non-empty" $mailto$
truncate -s 0 ~/nohup.out$
fi$
$
f=/tmp/tinderbox.logwatch.out$
if [[ ! -f $f ]]; then$
if [[ "$(wc -c ~/logs/* 2>/dev/null | tail -n 1)" != "0 total" ]]; then$
ls -l ~/logs/* >> $f$
head ~/logs/* >> $f$
echo -e "\nto re-activate this test again, do: rm $f" >> $f$
cat $f | timeout 120 mail -s "logs are non-empty" $mailto$
fi$
fi$
$
| Thx for the hint to look for commands inside of the script which might cause that error - I was somehow convinced that just the shebang line of the script itself could cause it, but ok ... |
|
Back to top |
|
 |
|