Infinite loop in FreeBSD
-
08-07-2019 - |
Question
I have a script that constantly segfaults - the problem that I can't solve as segfault is in python libxml bindings - didn't write those. Ok, so in Linux I used to run an inf.loop so that when script dies - it restarts, like so:
#!/bin/bash
while [ 1 ]
do
nice -n 19 python server.py
sleep 1
done
Well, I can't seem to find /bin/bash in FreeBSD so that doesn't work.
Any ideas? Consider that cron is not an option - allowed downtime is a few seconds.
Solution
/bin/sh almost certainly exists, but if you really need bash:
cd /usr/ports/*/bash
make install
that should install bash in /usr/local/bin/bash i believe
OTHER TIPS
There will be some shell program on the system, and that script looks like it will run in pretty much any shell.
Type type bash
to see where bash is. If not, try sh. It should be there, and it should work. Take the result of type bash
or type sh
, and use in in the place of /bin/bash. Alternately, look at /etc/passwd, look for your account, and notice what the shell is. I believe it's the last field, and it will say something like /bin/sh or /usr/bin/bash or whatever. Use that instead of /bin/bash.
Not sure what shell FreeBSD uses by default, but it probably comes with a few. The man page for whatever shell you are using ought to tell you that shell's loop syntax. It's probably pretty similar.