Launching multiple GUI programs from crontab - linux

I want to launch multiple GUI programs from crontab. I have tried the following, but it did not work:
export DISPLAY=:0.0 && task1
export DISPLAY=:1.0 && task2
When I execute above crontab commands, I am getting error as:
**No more handles [gtk_init_check() failed]**

1) You need to allow clients to connect from any host using xhost + <clientmachineName>
So it will look like:
hostmachine$ xhost + <clientmachineName>
2) Then connect to the client machine either directly or from any third machine where the VNC is enabled.
If you are using the third machine & not the client machine itself, then you need to enable x11 forwarding, by executing ssh -X <username#clientmachine>
3) After that you can open the gui application of the host machine, from the client terminal running on the client machine or the client terminal running on the vnc session of the third machine, for which export DISPLAY=<thirdmachine>:<sessionid no> is required.

Related

Is there a library to connect my Terminal using Robot Frmaework?

I want to run jobs in terminal connecting SSH tunnels. Is there any way that I can do it?
I should connect to Terminal
Access SSH tunnels
Access pentaho. sudo us - pentaho
Run my jobs
There is a SSHLibrary - https://github.com/robotframework/SSHLibrary & http://robotframework.org/SSHLibrary/SSHLibrary.html

Run a gui based application on a remote Linux machine using telnet

I need to run a gui-based application on a remote PC to which I am connected over telnet. The remote PC runs Linux Ubuntu 18.04
To figure out the screen, I run the following command on the remote machine:
echo $DISPLAY
which gave me :1 as result.
Then I run the program on the remote machine from my client (over telnet) using:
DISPLAY=:1 application_name
The program started correctly (since, in addition to the GUI, it prints some things on the command line) but the GUI didn't show up. But, if I run my app directly on the remote machine, everything is fine.
As a test, I tried to run firefox browser on an another machine (always through telnet) with the following command:
DISPLAY=:0 firefox
and it worked. Note: on the other machine the output of echo $DISPLAY was :0. Furthermore, I could not test my app on the second machine.
It seems that there are different settings between the two machines since what I'm trying to do works on a machine, but not on the other.
Do you have any idea of what type of setting should I check?
Did you try to run your application on the first remote machine but with DISPLAY=:0 instead of :1?
What is the error message you get from application when you started application in the first case ("DISPLAY=:1 app_name").

How to execute linux commands on a remote ubuntu server using symfony4?

I want to execute some linux commands like docker run nginx on a remote Ubuntu server. Let's say host A using my client interface on another host B developed in symfony4 and then the server (host A) will send some info after executing the command to the client interface on host B to be displayed on it.
How to achieve this?
at first you need to log in:
ssh username#ip_address_of_server_with_symfony4
Then
cd /path/to/symfony4
Then
docker exec symfony_container_php php bin/console command:name --arguments
If you need to run single command from your local computer, you also can use ssh -t
ssh -t user#ip full;command;separated with;-es

running SSH script command from jenkins using SSH

To deploy application on linux ubuntu server I have bunch of SSH commands that i currently run using PuTTY. The server has local account serviceaccount1. In PuTTY i connect to server using serviceaccount1 and executes the following commands one by one
cd /home/serviceaccount1/cr-ml
script /dev/null
screen -S data_and_status
cd cr-ml/notebooks
source activate crml
unset XDG_RUNTIME_DIR
jupyter kernelgateway --api='kernel_gateway.notebook_http' --seed_uri='data_and_status_api.ipynb' --port 8894 --ip 0.0.0.0
...
...
and so on
Now i want automate this using Jenkins. I installed SSH plugin, configured credential using SSH Username serviceaccount1 with private key
Then created a new jenkins project and added a build step Execute shell scripts on remote host using ssh and then add all the above commands.
When i build the jenkins project, it get stuck at executing 2nd command script /dev/null
i see the following console output
To me, it seems the culprit is the screen -S data_and_status command. Once you start a screen, I don't think you would be able to execute the subsequent commands over the SSH connection.
Alternatively, you can try using a tool like Ansible to run a bunch of commands against a remote server.

LINUX : Restart Gui app from a ssh console

I've a graphical program who has launched inside of the Front-End session.
I want to restart this application from putty, I can stop it by kill but I'm not be able to start application inside of the Front-End session.
When I Call application I get this error : cannot connect to X server
This may be way too late, but you can do it with these steps.
xhost +localhost
export DISPLAY=:0
restart_your_app_here
xhost command ensures your X server will take connections from the localhost.
export tells the X server where to send the X traffic (which is its own localhost).
Third command just restarts your app, you may want to do this in a tmux or screen so that the session doesn't get killed when you log out or get disconnected.

Resources