title: python restart after unexpected exit with `while true` loop
body: <p>l wrote a python script with <code>while true</code> to do task to catch email's attachment, but sometimes l found out it would exit unexpectedly on server.</p>
  
  <p>l run it on my local for more than 4 hours with no problem, so l can confirm that the code is correct.</p>
  
  <p>So is there a kind of mechanism to restart python when it exit unexpectedly, such as process monitoring? l am a novice in linux.</p>
  
  <p>remark: l run this python script like <code>python attachment.py &amp;</code> in a shell script.</p>