I have Debian OS, and I want to start shell script after lightdm is being logged in, how can I do that?
I tried to put
session-setup-script=/path/to/my/script in /etc/lightdm/lightdm.conf
file, but It won't work.
Any advice?
Try invoking your script in an ~/.xsession file.
This file is executed upon X server startup. More info here: https://unix.stackexchange.com/questions/47359/what-is-xsession-for
I was having the same issue and realised that I had set the option at the wrong point in /etc/lightdm/lightdm.conf, a silly mistake.
The seat defaults are documented before the [SeatDefaults] heading and I was placing my setting on the line below the documentation.
so
# session-setup-script = Script to run when starting a user session (runs as root)
session-setup-script=/usr/bin/bla
Looking further down the file I found the heading [SeatDefaults] and below that the setting.
#session-setup-script=
Un-commenting that line and setting the script worked as expected.
Related
I am working with Ubuntu 16.04 and I have two shell scripts:
run_roscore.sh : This one fires up a roscore in one terminal.
run_detection_node.sh : This one starts an object detection node in another terminal and should start up once run_roscore.sh has initialized the roscore.
I need both the scripts to execute as soon as the system boots up.
I made both scripts executable and then added the following command to cron:
#reboot /path/to/run_roscore.sh; /path/to/run_detection_node.sh, but it is not running.
I have also tried adding both scripts to the Startup Applications using this command for roscore: sh /path/to/run_roscore.sh and following command for detection node: sh /path/to/run_detection_node.sh. And it still does not work.
How do I get these scripts to run?
EDIT: I used the following command to see the system log for the CRON process: grep CRON /var/log/syslog and got the following output:
CRON[570]: (CRON) info (No MTA installed, discarding output).
So I installed MTA and then systemlog shows:
CRON[597]: (nvidia) CMD (/path/to/run_roscore.sh; /path/to/run_detection_node.sh)
I am still not able to see the output (which is supposed to be a camera stream with detections, as I see it when I run the scripts directly in a terminal). How should I proceed?
Since I got this working eventually, I am gonna answer my own question here.
I did the following steps to get the script running from startup:
Changed the type of the script from shell to bash (extension .bash).
Changed the shebang statement to be #!/bin/bash.
In Startup Applications, give the command bash path/to/script to run the script.
Basically when I changed the shell type from sh to bash, the script starts running as soon as the system boots up.
Note, in case this helps someone: My intention to have run_roscore.bash as a separate script was to run roscore as a background process. One can run it directly from a single script (which is also running the detection node) by having roscore& as a command before the rosnode starts. This command will fire up the master as a background process and leave the same terminal open for following commands to be executed.
If you could install immortal you could use the require option to start in sequence your services, for example, this is could be the run config for /etc/immortal/script1.yml:
cmd: /path/to/script1
log:
file: /var/log/script1.log
wait: 1
require:
- script2
And for /etc/immortal/script2.yml
cmd: /path/to/script2
log:
file: /var/log/script2.log
What this will do it will try to start both scripts on boot time, the first one script1 will wait 1 second before starting and also wait for script2 to be up and running, see more about the wait and require option here: https://immortal.run/post/immortal/
Based on your operating system you will need to configure/setup immortaldir, her is how to do it for Linux: https://immortal.run/post/how-to-install/
Going more deep in the topic of supervisors there are more alternatives here you could find some: https://en.wikipedia.org/wiki/Process_supervision
If you want to make sure that "Roscore" (whatever it is) gets started when your Ubuntu starts up then you should start it as a service (not via cron).
See this question/answer.
I am working on a BBB device running on an Angstrom image and the display panel is a 7 inch LCD cape. I want to start an application as soon as log-in message prompts means the application should get start automatically just after the booting. To achieve this I tried
1) To put my script files in /etc/init.d and linked the script with /etc/rc5.d as S99myscript and then updated the rc.d
But it was not an successful attempt.
2) I changed the /etc/issue file a little bit and to invoke the script i appended myscript file in the last as this.
. /home/root/myscript
// tried it like this also
sh . /home/root/myscript
but this time also i couldn't get my desired result.
What's i am missing ? Or how can I get the result.
The service file
Status of service file
So I have this really nasty problem.
I once set up a tomcat Server on my raspberry pi. The version of it was 8.0.24. I've created a bash script which sets the variable $CATALINA_HOME=/home/pi/apache-tomcat-8.0.24 on each start.
Meanwhile the directory is /home/pi/tomcat - i removed the useless information.
I've changed the export in /etc/init.d/tomcat also, but it didnt help.
After every restart, CATALINA_HOME is set back to /home/pi/apache-tomcat-8.0.24 again.
Is there a way to see, which script sets the environmental variable?
Somewhere I told linux to change the path at startup to /home/pi/apache.. , but i cant find where.
You can add a line in a few of the startup scripts to print the value of $CATALINA_HOME. Try adding:
echo "In $0, \$CATALINA_HOME is $CATALINA_HOME"
to your .bashrc before and after the call to /etc/bashrc
There's also a script called setenv.bash inside Tomcat that sets these types of variables. Take a look in there too.
This is not a duplicated question. The link suggested is for Shell Script, and I can launch node app via shell script doing normaly just 'node app', but for .desktop file, it does not work. So the answer linked never solve my problem, and what is the point to try to close the question suggesting to use an unsatisfied answer.
I simply try to exec node app from the current directory where .desktop file exists.
I do as follows, but for unknown reason, it does not work.
Surely, when I do node app on the directory, the node app launches as expected.
Any idea? Thanks.
[Desktop Entry]
Version=1.0
Name=JS Bin
Comment=JS Bin Offline REPL
Exec=node '"$(dirname "$1")"/app'
Icon=/home/ken/Google Drive/js-bin/code.png
Terminal=false
Type=Application
Categories=Utility;Application;
Exec=node '/home/ken/Google Drive/js-bin/app.js'
would be the same result.
Just in case, I don't have to re-login to make this work, correct?
SOLVED:
for node.js program, we should be careful for the path.
I have to do like
var app1 = proc.spawn(atom, [__dirname + '/app1.js']);
using __dirname properly, otherwise, PATH context problem occurs especially using shell script.
thanks.
On a Unix server, I am running an application engine via the process scheduler.
In it, I am attempting to use a "zip" Unix command from within an "Exec" pplcode function.
However, I only get the error
PS_Exec(P): Error executing batch command with reason: No such file or directory (2)
I have tried it several ways. The most logical approach I thought was to change directory back to the root, then change to the specified directory so that I could easily use the zip command, such as the following...
Exec("cd / && cd /opt/psfin/pt850/dat/PSFIN1/PYMNT && zip INVREND INVREND.XML");
1643 12.20.34 0.000048 72: Exec("cd /opt/psfin/pt850/dat/PSFIN1/PYMNT");
1644 12.20.34 0.001343 PS_Exec(P): Error executing batch command with reason: No such file or directory (2)
I've even tried the following....just to see if anything works from within an Exec...
Exec("ls");
Sure enough, it gave the same error.
Now, some of you may be wondering, does the account that is associated with the process scheduler actually have authority on this particular directory path on the server ? Well, I was able to create the xml file given in the previous command with no problems.
I just cannot seem to be able to modify it with the Exec issuance of Unix commands.
I'm wondering if this is an error of rights and permissions from the unix server with regards to the operator id that the process scheduler is running from. However, given that it can create and write to a file there, I cannot understand why the Exec command would be met with any resistance....Just my gut shot in the dark...
Any help would be GREATLY appreciated!!!
Thanks,
Flynn
Not sure if you're still having an issue, but in your Exec code, adding the optional %FilePath_Absolute constant should help. When that constant is left off, PS automatically prefixes all commands with <PS_HOME>. You'll have to specify absolute paths with this flag on though. I've changed the command to something that should work.
Exec("zip /opt/psfin/pt850/dat/PSFIN1/PYMNT/INVREND /opt/psfin/pt850/dat/PSFIN1/PYMNT/INVREND.XML", %FilePath_Absolute);
The documentation at PeopleBooks is a little confusing sometimes, but it explains it fairly well in this case.
You can always store the absolute location in a variable and prefix that to your commands so you don't have to keep typing out /opt/psfin/pt850/dat/PSFIN1/PYMNT/.