LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Run script after auto login on graphical system (https://www.linuxquestions.org/questions/linux-newbie-8/run-script-after-auto-login-on-graphical-system-760541/)

Lieve 10-08-2009 07:55 AM

Run script after auto login on graphical system
 
Hi,

I was wondering if there is a way to run a script after the autologin (don't shoot me, I'll explain why) on a restart of a server.

The reason I'm asking this is that I need to execute a command to start a process on the server whenever the system is rebooted BUT this command can ONLY be run from a graphical interface..

If possible I'd like to prevent any "user-action" if the server was rebooted so any tips would be very much appreciated!

Thank you very much for your help!
Regards

lutusp 10-08-2009 02:54 PM

Quote:

Originally Posted by Lieve (Post 3712202)
Hi,

I was wondering if there is a way to run a script after the autologin (don't shoot me, I'll explain why) on a restart of a server.

The reason I'm asking this is that I need to execute a command to start a process on the server whenever the system is rebooted BUT this command can ONLY be run from a graphical interface..

If possible I'd like to prevent any "user-action" if the server was rebooted so any tips would be very much appreciated!

Thank you very much for your help!
Regards

Put the command in the autologin user's .bashrc configuration file. Commands in this file are executed as the last step in the login process.

Lieve 10-09-2009 12:50 AM

Isn't that going to make it execute whenever that user logs in? Because it has to be executed only once.. when the server is booted...

Or am I wrong here?
Thank you!

lutusp 10-09-2009 01:09 AM

Quote:

Originally Posted by Lieve (Post 3713090)
Isn't that going to make it execute whenever that user logs in? Because it has to be executed only once.. when the server is booted...

Or am I wrong here?
Thank you!

Well, I would have suggested putting a command in /etc/rc.local, except that you specified it must be run from a graphical environment.

In fact, here are the two requirements you have specified:

1. "it has to be executed only once.. when the server is booted ..."

2. "this command can ONLY be run from a graphical interface..."

You cannot have both. You must decide which one you want more, and abandon the other.

Quote:

Or am I wrong here?
It's not an issue of right and wrong, it's an issue of feasibility.

catkin 10-09-2009 04:57 AM

Quote:

Originally Posted by lutusp (Post 3713107)
Well, I would have suggested putting a command in /etc/rc.local, except that you specified it must be run from a graphical environment.

In fact, here are the two requirements you have specified:

1. "it has to be executed only once.. when the server is booted ..."

2. "this command can ONLY be run from a graphical interface..."

You cannot have both. You must decide which one you want more, and abandon the other.

What if boot was followed by auto-login? Then the program could be started using the Desktop session autostart facilities. A marker file, deleted during boot, could be used to ensure the program was only run once per boot, not every time the user starts a desktop session.

BTW, needing to do this is a ugly hole to have gotten into :jawa:

lutusp 10-09-2009 04:59 AM

Quote:

Originally Posted by catkin (Post 3713275)
What if boot was followed by auto-login? Then the program could be started using the Desktop session autostart facilities. A marker file, deleted during boot, could be used to ensure the program was only run once per boot, not every time the user starts a desktop session.

BTW, needing to do this is a ugly hole to have gotten into :jawa:

I had considered that arrangement, but I thought it might be a bit much for the OP. It would certainly work and meet both requirements.


All times are GMT -5. The time now is 05:44 PM.