2

In 2020 (last day today too), Fedora 33, what is the ideal way to run a command or script at startup?

I am asking this again because over the years I have seen several different ways of doing it, some of which are now obsolete, so in 2020, what is the ideal way to do this?

olfek
  • 711
  • 3
  • 7
  • 20

3 Answers3

1

I was able to do this by creating my own .desktop file in ~/.config/autostart. I'm running Fedora Cinnamon Edition, not sure if this works in other distributions.

Example: Create a file named discord-desktop.desktop with the following content. On the restart, discord will start minimized.

[Desktop Entry]
Name=Discord Desktop
Comment=Discord Desktop for Linux
Exec=flatpak run com.discordapp.Discord --start-minimized
Type=Application
Abdul Rehman
  • 184
  • 1
  • 10
olfek
  • 711
  • 3
  • 7
  • 20
1

I'd put the command in root user's crontab with @reboot directive, i.e.

@reboot /root/myscript.sh

It's a quick and easy way to put small, quick commands to run at startup.

Adrian
  • 2,366
  • 1
  • 10
  • 9
0
  • Create a systemd unit
  • put it into /etc/rc.d/rc.local (that's a file not a directory) and enable it:
sudo systemctl enable rc-local.service
Artem S. Tashkinov
  • 26,392
  • 4
  • 33
  • 64