#!/usr/bin/perl # check_if_its_running.pl use strict; use warnings; my $line; my $checkme = "/home/mojodaddy/checkme.txt"; start_it(); while (1) { open CHECKME, "<$checkme" || die "Couldn't open checkme file: $!\n"; while (){ # get the line with the name of the tempfile $line = $_; } close CHECKME; if (-e $line){ # see if the file exists print "(Checker says: 'Woo-hoo! Script is still running!')\n"; sleep 10; } else{ print "(Checker says: 'Doh! Script stopped running! I'd better restart it.')\n"; start_it(); } } sub start_it { system("perl always_be_running.pl"); }