Run Google Chrome 24/7

November 4, 2019 132 views
Ubuntu 18.04

I want to run Google Chrome 24/7 because there is an extension I need to use.

I have installed XFCE and TightVNC as described here:

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-16-04

and is working fine, I can login, see the desktop, execute chrome, my extension is running, everything is ok.

The problem is if I kill the vncserver then Chrome stops working (I think this is because vncserver is starting xfce?)

I’m very noob on these things please could you tell me what is the best way to keep Google Chrome open 24/7 (even if the system restarts or Chrome stops working).

1 Answer

Hi @enriquepiatti,

You can create a bash script to check if the service vncserver is actually running. If the service is not running start it.

You can see if a service is running with the following

systemctl show -p ActiveState NameOfService

It will show if the service is active,inactive or dead. Based on this output, you can actually decide whether to try and start it or leave as it is.

Once you create the bash script, add it as a cron job to be executed every minute. This should be enough to solve your problem.

Regards,
KDSys

  • Thanks I will try it, that will work even if I close the SSH terminal right? I was thinking in adding a @reboot line to crontab too, but what will be the owner in that case? I mean, if the system is reboot, the cron will run the @reboot line with “root” instead of my user?

    • Hi @enriquep,

      Yes this will work even if you close your SSH session.

      As for the reboot option, this is not a good idea as it will reboot it every time, even when the service is active.

      As for the user itself, you can create the cron to be executed under the user you wish like

      crontab -u UserName -e
      

      Regards,
      KDSys

Have another answer? Share your knowledge.