Time limit in an executable

310 views Asked by At

How can I make an executable in linux ubuntu with time constraint meaning that I want the executable to run only for 90 days in the machine where I deploy it? So the user can only use the executable for 90 days and not more. Similar to some softwares which has free trial period for 1 month.

1

There are 1 answers

0
thomasfedb On

While it is difficult to guard against modification of the executable file, in theory you can do this with a trivial implimentation in your code.

For example, in C:

int main() {
  if (time(NULL) > xxxxxxxxxxxx) {
    return 0;
  }
}

This relies on setting the time to expire at compile-time.

If you want to have the trial last a certain period, rather than expire at a particular predetermined time, then you would have to get the program to write a file on first execution that specifies the time it was run. You can then later compare the current time with this file.

These methods can be avoided by savvy users, and so you may wish to pursue other methods, perhaps increasing obscurity, or involving some server that you own in a critical software function.