Chromedriver closes after running nohup on google cloud - linux

I have got a simple script which uses selenium and chromedriver. I have installed the chrome. When I run the script using the command nohup python3.7 -u main.py & tail -f nohup.out everything works; script works as it should. When I close the window of the google cloud ssh the scripts stop working. When I reopen the ssh and call tail -f nohup.out I receive such an error
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
(Session info: headless chrome=75.0.3770.142)
I was using the chrome version 87 and read that downgrading it should help, so I downgrade it to 75.
It is run on ubuntu, chrome and chromedriver version are 75. Is there such a command that would make chromedriver not close after closing the ssh window?

You can start processes in background in Linux. They will continue running even when you log off (which closing SSH window essentially is).
There are several ways:
Using bg & disown - as described here
Using screen as described here
You can go through entire thread to get more ideas. I'd recommend using bg & disown - it works well on Ubuntu provided by GCP however you can try out various solutions and pick the one that suits your needs the best.
From my experience - I was using screen for many things - including virtualbox and it worked - it may be more cumbersome if you want many processes to run in background but if that's just one its pretty easy.
Install screen: sudo apt install screen, run it with screen and treat it as another screen, run whatever you want and then just press ctrl + a d and you will be back to "original" shell. If you want to resume yor screen sessions type screen -r. You will find even more about using screen here.

Related

running node js app in background in ubuntu

I have a nodejs compiled application that I run from a terminal window on my ubuntu vps.Is there a way to run it in the background, meaning i can afford to close my terminal window and it still works. Note this exe prints the messages on the terminal window when its running
tried PM2, it errors out saying "awaiting restart"
tried nohup, it does not error out and shows process has started but exe does not what it shall do, meaning its not working.
if i do ./app , it works but then i can not close the terminal window.
used tmux, loving it so far.
think might use PM2 with tmux where i can.

How to terminate terminal that is connected to a AWS box but still leave process on?

I have ssh'd into a ubuntu AWS box via terminal on mac. I have successfully setup the process I want to run in the box.
How do can exit out of terminal without killing the process running?
Thank you in advance.
P.S
New to linux and terminal on mac
Personally I use screen to get in/out of the system while keeping the processes running.
$ sudo apt install screen
To create a new screen:
$ screen -S screen_name
Then do something in your screen, for example running a program, editing files, downloading file with wget, etc.
Later if you want to exit the terminal without killing the running process, simply press Ctrl+A+D.
The process will kept running in the background inside the screen
To reconnect to the screen:
$ screen -R screen_name

linux running program to be shown again when console closed unfortunately

I am running a automatic installation in linux by running some command in cli
root#server$ sudo install some-devl
if unfortunatly even before the installation finishes the console become closed (putty to assume )
we can check if that is running or not by relaunching and running putty again with login
ps -eaf | grep install*
but is the anyway to continute to show in install output on screen again ?
One way to make your session resilient to disconnections is to use the screen command.
Another thing to try is to prevent the disconnects in the first place. One way is to set a keep alive.

xfce-session without panels on cygwin

My cygwin workflow is as follows
Run XServer
Start xfce session (by running xfce4-session)
Start xfce4-terminal
Everything works well, except that xfce4-session seems to bring up an empty floating-panel, which I'm unable to hide without killing the session itself. Is there a way to configure xfce so this panel doesn't get shown?
PS: Running xfce4-terminal by itself gives me the terminal emulator, but the terminal behaves nicer when xfce4-session is active--text is anti-aliased, icons are slicker, etc.
Try killing just the panel process itself:
killall xfce4-panel
I believe the right way to start xfce is running /usr/bin/startxfce4.
If you want to run it the way you are, perhaps you could right click on the panel and click remove to get rid of it.
xfwm4 is the Window Manager, xfce-session is the session manager which "Restores your session on startup and allows you to shutdown the computer from Xfce."
I just found out that running xfsettingsd will load the XFCE theme and settings.
Using that command you can initiate the XFCE configuration without running the full desktop environment.
xfsettingsd &; xfce4-terminal;

Using script to automatically start program when the system boot up (linux, shell)

Here is the situation, I'm planning to use a simple script to start a program call "STAF", when the Suse system is fully booted. I have achieved this by putting it in the "/etc/init.d/", but this script is basically executed at the background, which means that I cannot see its progress.
When the "STAF" is started this way it works but it doesn't show any working progress when its running service (for example ping, or system backup), instead if I start the "STAF" manually by running the same script whit a terminal, the working progress of "STAF" can be seen on the terminal. Its sort of like the program needs to be started with a interactive terminal, but how can I make this starting process automatic and it should imitate human opening a terminal and run the script?
Sorry if I explained it poorly because its a confusing situation. Thanks.
First, go to the KDE Startup and Shutdown options under System Settings. Then add this command as a new startup script:
konsole -e bash nameofyourscript.sh
I believe the screen utility can do what you describe. Instead of running STAF on startup, you would run screen STAF. To open that terminal, you would run screen -ls to get the screen ID, and screen -r ... to open it.
(Disclaimer: I have not tried this.)

Resources