How to add executable bash script on ubuntu startup
Solution 1
One more option is schedule a job at boot time
crontab -e
Choose an editor to open the cron job file. Append the following with your script name
@reboot path/to/script.sh
In your case
crontab -e
@reboot /home/user/Documents/file.sh
Make sure the script has executable permission.
Solution 2
So I have succesfully run the script using my method itself (System > Preferences > Startup Applications). These are the changes I made to my script.
Added this line at the top of my script
#!/bin/bash
Then made executable using this command
chmod u+x file.sh
rebooted the system
Solution 3
In addition to what Eka says, make sure your .desktop
file, in ~/.config/autostart/
, contains the following lines:
Terminal=false
Type=Application
This did the trick to me.
Related videos on Youtube
Eka
Updated on September 18, 2022Comments
-
Eka over 1 year
I have created a executable bash script (using chmod +x) for monitoring my system and it works perfectly with out any error. Now i want to add this script on my start up in order to executing the script on every reboot. I have saved this executable file in my documents folder like this
/home/user/Documents/file.sh
For running this script on start up; from dash i searched and selected "Startup Applications" and added the details and location of the script and done a fresh reboot. But even after a fresh reboot the script is not working but the script is executing when i do it with terminal (eg
./file.sh
). What changes should i make it to run my script on start up. If it helps this is the attribute of my script-rwxrwxr-x ;using ls -l
-
Byte Commander about 9 yearsPlease clarify which file you mean. It's unclear, although your answer might be 100% right... You could eventually also give a valid example.
-
Roman over 8 yearsI did all of these without success. The script just does not execute on startup. Anything else you did? (My script automatically opens all the windows I use every day)