You are not logged in.

#1 2009-12-15 10:45:42

pedrojoxe2
Member
Registered: 2009-12-15
Posts: 2

[Solved] Execute script on startup

Hello.

I would like to execute a little script when linux starts or when the Desktop Environment starts. How could I do it?

Thank you.

Last edited by pedrojoxe2 (2009-12-15 13:19:26)

Offline

#2 2009-12-15 10:58:33

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,474
Website

Re: [Solved] Execute script on startup

add it to ~/.xinitrc

Online

#3 2009-12-15 12:02:39

ZaQ
Member
Registered: 2009-12-12
Posts: 106

Re: [Solved] Execute script on startup

Offline

#4 2009-12-15 12:17:51

sHyLoCk
Member
From: /dev/null
Registered: 2009-06-19
Posts: 1,197

Re: [Solved] Execute script on startup

Put the script in:

~/.config/autostart and make sure to chmod +x it.

Regards


~ Regards,
sHy
ArchBang: Yet another Distro for Allan to break.
Blog | GIT | Forum (。◕‿◕。)

Offline

#5 2009-12-15 12:33:55

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,094

Re: [Solved] Execute script on startup

sHyLoCk wrote:

Put the script in:

~/.config/autostart and make sure to chmod +x it.

Regards

Only if he runs a wm/de that actually executes that file.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#6 2009-12-15 12:36:44

sHyLoCk
Member
From: /dev/null
Registered: 2009-06-19
Posts: 1,197

Re: [Solved] Execute script on startup

Mr.Elendig wrote:
sHyLoCk wrote:

Put the script in:

~/.config/autostart and make sure to chmod +x it.

Regards

Only if he runs a wm/de that actually executes that file.

Yep. If the OP doesn't clearly state his wm/de there can be 100s of answers. Like putting it in rc.local

Note: he says at Linux startup or de startup.

Regards

Last edited by sHyLoCk (2009-12-15 12:37:54)


~ Regards,
sHy
ArchBang: Yet another Distro for Allan to break.
Blog | GIT | Forum (。◕‿◕。)

Offline

#7 2009-12-15 13:28:22

pedrojoxe2
Member
Registered: 2009-12-15
Posts: 2

Re: [Solved] Execute script on startup

Ok, thanks to everybody. Finally I found another solution for my problem instead of executing a script every time I start linux. But I'll save your answers in case I want to do it in the future.

Thank you.

Offline

#8 2009-12-15 18:22:28

ZaQ
Member
Registered: 2009-12-12
Posts: 106

Re: [Solved] Execute script on startup

Good, but maybe it could help other people if you post your solution...

ZaQ

Offline

#9 2017-04-02 15:41:53

tunnelrat
Member
Registered: 2017-04-02
Posts: 1

Re: [Solved] Execute script on startup

Here is how to autostart scripts:
-------------------------------------------------------------------
Create a new file in "/etc/systemd/system/" (e.g. script.service) and add the following contents:

[Unit]
Description=Script

[Service]
ExecStart=/usr/bin/script

[Install]
WantedBy=multi-user.target 

put your script in "/usr/bin/" and make sure to make it executable. and then enable the service.

$ sudo chmod 755 /usr/bin/script
$ sudo systemctl enable script.service

The next time yout restart the script should autostart

If you want the script to run without restarting, type:

$ sudo systemctl start script.service

Last edited by tunnelrat (2017-04-02 15:44:02)

Offline

#10 2017-04-02 15:59:49

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 12,415
Website

Re: [Solved] Execute script on startup

Please do not necrobump, especially solved threads, and especially when the information is already well documented on the wiki.

Closing.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB