8

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
0

3 Answers 3

11

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.

1
  • 1
    Please clarify which file you mean. It's unclear, although your answer might be 100% right... You could eventually also give a valid example.
    – Byte Commander
    Commented Mar 31, 2015 at 17:07
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

1
  • 1
    I 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)
    – Roman
    Commented Oct 29, 2015 at 7:11
1

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.

Not the answer you're looking for? Browse other questions tagged .