title: Automated scripts on a Linux Server (not cron jobs)
body: <p>I am programming a website on a Linux CentOS server (I am planning to upgrade to a VPS plan where I will have root access). Much of the website will rely on scripts that are automated.</p>
  
  <p>I have 2 questions about starting automated processes.</p>
  
  <ul>
  <li><p>Is there any way I can start a Daemon thread, or anything like that, which will constantly be running. I need to execute a script every time an email account gets a new e-mail. I am aware of cron jobs that can run every minute, but having a script that constantly runs would be ideal, so I can execute the script the moment a new e-mail arrives.</p></li>
  <li><p>Is there any way from code (ideally PHP) to start a thread, which runs concurrently with the main program. In the script I am using, the imap_open is used to connect to an e-mail account, which takes a few seconds every time. However, if I could fire off multiple concurrent scripts at the same time, that would ideally reduce the program's time. Is there any way to do this?</p></li>
  </ul>
  
  <p>Any help with these questions would be greatly appreciated.</p>