I have shell scripts like#!/bin/bashwhile true;do   #Code HERE!   #Pushing Data to DB   echo Data to DB> /root/schip.log 2>&1doneThis is script is continuously running and gathering info on server and then sending data to DB(TimeStamp DB). I don't why, sometimes the scripts are dieing. In logs I can't see any thing. In same way, I saw in Python script. Python script like thisimport <stuff>while True:   #Code HERE   #Push data to DB   print Data to DBSo, what could be the reasons?, how do I prevent? and how can I enable the logs(In python and Shell) to know the reason?. Thanks!
what could be the reasons for shell scripts kill itself?
shell script;python
A few things that may cause a shell to exit (not exhaustive):calling the exit utility. Let's not forget about the obviouscalling the return utility. In the case of bash that will return only if in a function or sourced file.exec cmd. That will execute cmd in the same process so in effect breaking out of that loop. The script will end when cmd exits.set -e/set -o errexit is enabled (see also the SHELLOPTS environment variable for bash) and a command exits with an error.set -u/set -o nounset is enabled and an unset variable is referenced.a DEBUG or ERR trap is defined that calls exit.Failing special builtins. Failure of special builtins (like set, :, eval...) causes the shell to exit. In the case of bash though, that only happens in POSIX mode (like when POSIXLY_CORRECT is in the environment or when invoked as sh...) and even then not for all special builtins. For instance : > / will cause the shell to exit.as mentioned by @schily, syntax error (like in code that is only reached conditionally).division by 0 (in $((1/x)) or ${array[1/x]}).internal bash error for instance because some limit is reached:fails to allocate memoryfails to fork a processstack size exceeded (for instance when using function recursion)Some other limits in place via ulimit (which may also cause some signals to be sent).killed by a another process. Another process can call kill() to explicitly kill the interpreter of your script.killed by the system.SIGINT/SIGQUIT. If you press ^C/^\.SIGHUP. If the terminal is disconnected.SIGSEGV/SIGBUS/SIGILL. The bash command does something wrong (a bug) or failing hardware (memory).SIGPIPE: builtin (echo, printf) writing to a now-closed pipe or socket (could also happen for error messages if stderr is a pipe).The first thing to check would be the error messages and the exit status.