nonstop

run a command and start it again when it finishes
git clone https://noulin.net/git/nonstop.git
Log | Files | Refs | LICENSE

nonstop.c (581B)


      1 #! /usr/bin/env sheepy
      2 /* or direct path to sheepy: #! /usr/local/bin/sheepy */
      3 
      4 #include "libsheepyObject.h"
      5 #include <unistd.h>
      6 
      7 int argc; char **argv;
      8 
      9 int main(int ARGC, char** ARGV) {
     10 
     11   argc = ARGC; argv = ARGV;
     12 
     13   initLibsheepy(argv[0]);
     14   setLogMode(LOG_VERBOSE);
     15 
     16   if (argc < 2) {
     17     puts(BLD RED "Command argument missing" RST);
     18     XFAILURE;
     19   }
     20 
     21   forever {
     22     logI(BLD GRN "------- NONSTOP START ------------" RST);
     23     system(argv[1]);
     24     logI(BLD YLW "------- NONSTOP COMMAND END ------" RST);
     25     logI("sleeping 5s - press ctrl-c to exit");
     26     sleep(5);
     27   }
     28 }