Bash script to monitor and (re)start Webmin

Bash script to monitor and (re)start Webmin

Webmin (Virtualmin) has great service monitoring capabilities, restarting any failed services that it detects. Unfortunately, it cannot and does not monitor or restart itself it it crashes.

Unfortunately, since Webmin has no central executable (being a Perl script), scanning for it in the process list is not the easiest task to perform via a bash script.

Still, since on (most) Linux systems it comes with a service manager, this can be used to check its status.

The script below was tested and works on CentOS (and should work on all compatible systems: Fedora, RHEL)


# le: 20131222
if /sbin/service webmin status | grep "stopped" > /dev/null
    echo "Webmin is stopped. Restarting..."
    /sbin/service webmin start
    echo "Webmin is running."


The script can be saved to a file, chmod-ed 777 and then set as a periodic cron job.

Leave a Reply