Command line snippet of the week: 3

Wouldn’t it be nice to check if a program is running? You can do that and make it start conditionally if it isn’t running. Very handy for service daemons that always need to be running. Can be used with cron as well:

ps -C servicedaemon || { servicedaemon & }

Replace servicedaemon with your own process that needs to be checked. The second servicedaemon value describes what program it needs to start if it’s not running.