Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
Created July 7, 2016 22:01
Show Gist options
  • Select an option

  • Save gregjhogan/b0f858fe078bd4f84170ee2a18a9bde6 to your computer and use it in GitHub Desktop.

Select an option

Save gregjhogan/b0f858fe078bd4f84170ee2a18a9bde6 to your computer and use it in GitHub Desktop.
cron job to keep process running
#!/bin/sh
# crontab: * * * * * /{path}/{to}/{script}.sh
ps -ef | grep 'node {script}' | grep -v grep > /dev/null
if [ $? != 0 ]
then
cd /{working}/{dir}
nohup node {script} > /dev/null 2>&1 &
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment