Home > Net >  Autorun console application in linux
Autorun console application in linux

Time:08-09

I have developed a console application using MVS and I compiled it so can run on linux.

It runs on linux when I manually run and everything works so far. But whenever I try to run it at boot using crontab it seems not to be working.

My application is a HttpListener. The linux environment I run this is a robot's. I've not used linux very much so I have found and used the below commands to get this run at boot.

@reboot /home/rauman/Downloads/webserver

Then I tried setting a delay of 20secs,

@reboot sleep 20 && /home/rauman/Downloads/webserver

I normally run this application with terminal like below and works fine

./webserver

I'm accessing the robot using putty

After adding this to run at boot, I could see the pid of the application,

pidof webserver

So I guess it runs, but got no permission or something?

I have given permission for the file using,

chmod  x webserver

Any help is appreciated.

Edit : Solved

As, Mr. R pointed out

@reboot sleep 20 && cd /home/rauman/Downloads/ && /.webserver

CodePudding user response:

I ran into the same problem a few days ago. My app runs flawlessly when I call it from its working directory but it failed when getting called from outside. It turned out the app reads a file by a relative address. So I had to change either the program or the pwd.

The easiest way that I came by is changing pwd:

@reboot sleep 20 && cd /home/rauman/Downloads/ && ./webserver

CodePudding user response:

crontab runs processes as root, so any another file (such configurations) beloning to your user profile folder cannot be accessibile by ¢rotab.

Is this you scenario?

If yes, you should them into /etc or into /root.

  • Related