# [solved]after reboot:/bin/sh: bad interpreter: Permission d

## toralf

I do wonder about getting this error message from cron via email at a hardened Gentoo server (only once immediately after reboot) :

```
/bin/sh: /home/tinderbox/tb/bin/logwatch.sh: /bin/sh: bad interpreter: Permission denied
```

The appropriate cron entry is:

```
$ crontab -l

*/1  * * * * ~/tb/bin/logwatch.sh
```

and the script itself is just sth like.

```
$ 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 enoughLast edited by toralf on Fri Apr 07, 2017 9:35 am; edited 1 time in total

----------

## khayyam

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:

```
# 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:

```
*/1  * * * * sh /home/tinderbox/tb/bin/logwatch.sh
```

best ... khay

----------

## toralf

Well, 

```
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 ...

----------

