Monit runs as a regular user, no need for root!
Monit is sufficiently flexible that you don't even need PIDFILES, you can just reference the program by a regex expression!
Get the binaries here:
You need a
.monitrc file on the user you'll run the process.
The real magic happens on the line that references the process
banbylog, which you'll have to adjust to your own needs.
It basically matches a
java program that has a multitude of chars and then the string
banbylog. You can search for your own processes using something like
ps -ef | grep java.
The last part of the string,
start program instructs monit on how to start your process/service. In this case we're referencing
/frankie/_banbylog.sh which is just a simple bash script:
#!/bin/bash java -cp /frankie/banbylog/BanByLog-1.0.jar \ com.wasteofserver.banbylog.StartLooking >> \ /frankie/banbylog/banbylog.log 2>&1 &
And here are some useful commands you'll probably want to try:
monit -t - test if config file syntax is correct
monit -d 10 - launch monit as a daemon, checking processes every 10 seconds
monit status - will present you with something like this:
[email protected]:~# monit status Monit 5.32.0 uptime: 17m Process 'banbylog' status OK monitoring status Monitored monitoring mode active on reboot start pid 9610 parent pid 1 uid 0 effective uid 0 gid 0 uptime 1d 14h 6m threads 20 children 0 cpu 0.1% cpu total 0.1% memory 2.2% [87.2 MB] memory total 2.2% [87.2 MB] (...)
That's pretty much it. There is much more to monit, but this should allow you to start playing with it.
As an Amazon Associate I may earn from qualifying purchases on some links.
If you found this page helpful, please share.