Page 1 of 1

How to run commands on startup

Posted: Wed Jan 16, 2013 11:10 am
by Taffman
I need to run the following commands each time I boot up:

sudo setserial /dev/ttyS4 uart 16550A
sudo setserial /dev/ttyS5 uart 16550A
sudo setserial /dev/ttyS6 uart 16550A
sudo setserial /dev/ttyS7 uart 16550A

I have tried adding them to /etc/rc.local but i don't think Mint reads this file on startup.

an anyone tell me where I can store the above commands so that they are executed on startup please?

Re: How to run commands on startup

Posted: Wed Jan 16, 2013 11:33 am
by russellz
Try /etc/init.d/rc.local ?

Russell.

Re: How to run commands on startup

Posted: Wed Jan 16, 2013 12:15 pm
by viking777
Commands executed from /etc/rc.local (or /etc/init.d/rc.local if you decide to try that) are run as root so they do not require sudo. Remove sudo from the commands and see if it makes any difference - I don't know if it will, but it is worth a try.

Re: How to run commands on startup

Posted: Wed Jan 16, 2013 1:08 pm
by Taffman
Nope, that didn't work either.

Re: How to run commands on startup

Posted: Wed Jan 16, 2013 1:26 pm
by viking777
OK lets start with the simple questions - have you tried running these commands after startup from a terminal and if so do they work - you haven't said. Without an answer to that question everything else is irrelevant.

Re: How to run commands on startup

Posted: Wed Jan 16, 2013 1:27 pm
by Taffman
These commands work when manually entered in Terminal.
but these settings do not persist after a reboot.


not sure if I need "sudo" here though, i do in Terminal from my user account.

Re: How to run commands on startup

Posted: Wed Jan 16, 2013 1:47 pm
by viking777
OK this is what I would try:

Make a shell script from the commands you want to run:

Code: Select all

#!/bin/bash

setserial /dev/ttyS4 uart 16550A
setserial /dev/ttyS5 uart 16550A
setserial /dev/ttyS6 uart 16550A
setserial /dev/ttyS7 uart 16550A
Save it as setserial.sh and make it executable. If, as you say above you don't need sudo to run these commands you can save it to your home folder.

Now go to the program 'Startup Application' and add a new entry. Call it Setserial (or anything you like it doesn't matter) make the command to run

Code: Select all

/home/yourusername/setserial.sh
I hope you appreaciate that it has to be your real username, not what I have just typed.

I start several programs this way and it always works for me, if it doesn't then it may be a permissions issue in which case my instinct would be to move setserial.sh to /usr/bin and change the ownership to root. I don't know if this works - I have never tried it.

Re: How to run commands on startup

Posted: Wed Jan 16, 2013 1:52 pm
by Taffman
Ok I'll try that. thanks for your help.

Re: How to run commands on startup

Posted: Wed Feb 20, 2013 1:32 pm
by Taffman
I cant seem to get any scripts to run on startup using the Startup Applications menu option or by adding commands to /etc/rc.local
Anyone know the trick to this?

Re: How to run commands on startup

Posted: Wed Feb 20, 2013 1:53 pm
by bigj231
Did you set the script to executable?

Code: Select all

chmod 775 yourscriptnamehere

Re: How to run commands on startup

Posted: Wed Feb 20, 2013 1:57 pm
by Taffman
Yep tried that still doesn't work.

Re: How to run commands on startup

Posted: Thu Jun 18, 2015 7:31 pm
by johnywhy
for those looking here for a solution:
Open the "Session and Startup" application.
Go to the "Application Autostart" tab.
Add each command as a separate entry.
Done.

Re: How to run commands on startup

Posted: Fri Jun 19, 2015 11:19 am
by Habitual
Taffman wrote:Nope, that didn't work either.
try /path/to/setserial on each of those lines in /etc/rc.local or in the script if one is used for it in /etc/rc.local

Re: How to run commands on startup

Posted: Fri Sep 11, 2020 4:45 am
by amit_27
johnywhy wrote: Thu Jun 18, 2015 7:31 pm for those looking here for a solution:
Open the "Session and Startup" application.
Go to the "Application Autostart" tab.
Add each command as a separate entry.
Done.
Thank you! I was looking at this post for a solution. This worked really well for me. Much appreciated :)