Auto script execution on user login

General support questions
Post Reply
pmattt
Posts: 2
Joined: 2017/11/02 06:25:50

Auto script execution on user login

Post by pmattt » 2017/11/02 06:52:49

Hi,

I am migrating my application from centos 6 to centos7.
I want some commands to be executed on user login.in centos 6 I have added these commands to .xinitrc file located in home directory of the user. This script is executing fine on user login.

But in centos7 this file is not executing automatically on user login.
Do I nee to change anything to auto execute .xinitrc file on user login in centos7?
Or I can achieve this in any different way.
Please help...
Thanks in advance...

Regards,
Prasanth

kt53
Posts: 48
Joined: 2016/05/12 05:12:02

Re: Auto script execution on user login

Post by kt53 » 2017/11/04 23:51:55

Hello:

There is probably a better way, but here is how I do it.
I have a scripts that launches a desktop clock (tzclock by Chris Knight), and I put the path to the script
as last line in my " .bash_profile " file.

Code: Select all

~/Documents/tzclock/mycity.sh
Also, make sure that your scripts are executable

Code: Select all

chmod ugo+x <script_file>
Regards,
KT

pjsr2
Posts: 614
Joined: 2014/03/27 20:11:07

Re: Auto script execution on user login

Post by pjsr2 » 2017/11/05 11:10:54

Create a .desktop file that performs the actions you want. Then install that .desktop file in the $HOME/.config/autostart directory.
If you want to execute this for every user on login, put the .desktop in the /etc/xdg/autostart directory.

pmattt
Posts: 2
Joined: 2017/11/02 06:25:50

Re: Auto script execution on user login

Post by pmattt » 2017/11/21 04:28:24

pjsr2 wrote:Create a .desktop file that performs the actions you want. Then install that .desktop file in the $HOME/.config/autostart directory.
If you want to execute this for every user on login, put the .desktop in the /etc/xdg/autostart directory.
This worked for me :D .
But still I am facing some issues ,
In my .desktop file I am invoking a shell script. From this shell script I am executing two commands.
one command is to start a bat file and another command to start fvwm window manager.
When I execute these, the system is getting hanged.

If I start the script saperately it is working without any issue. Issue happens only when script executed from .desktop file.

The execution time for these two commands is little high. So when two commands trying to execute simultaneously this issue happens.
When I put a 20s wait, This issue is solved. But putting sleep is not a recommended approch.

Can anyone suggest a better approch

Please help....

Post Reply