Skip to content

Instantly share code, notes, and snippets.

@himalay
Last active August 3, 2017 14:48
Show Gist options
  • Select an option

  • Save himalay/457d63a2e89a28165c69e28ac15e0a03 to your computer and use it in GitHub Desktop.

Select an option

Save himalay/457d63a2e89a28165c69e28ac15e0a03 to your computer and use it in GitHub Desktop.
keep something alive in linux box
#!/bin/bash
ps -ef | egrep "node.+app.js" > /dev/null
if [[ $? -ne 0 ]]; then
pm2 start 2 // node process manager
echo "`date` : app started." >> ~/app.log
fi
# cron
*/5 * * * * /home/user/bin/node_app.sh
#----------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment