How to run commands on startup

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
User avatar
Taffman
Level 3
Level 3
Posts: 108
Joined: Fri May 06, 2011 10:51 am
Location: United Kingdom
Contact:

How to run commands on startup

Postby Taffman » Wed Jan 16, 2013 11:10 am

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?
Linux Mint 17 Cinnamon 32-bit, Dell Dimension 9200, 4GB, 2.4GHz Core2, Radeon X1300

User avatar
russellz
Level 2
Level 2
Posts: 97
Joined: Sat Nov 24, 2012 7:02 am
Location: Millas, France

Re: How to run commands on startup

Postby russellz » Wed Jan 16, 2013 11:33 am

Try /etc/init.d/rc.local ?

Russell.
Laptop: Toshiba Satellite C870 13V . Mint Cinnamon 17.3
Desktop: Gigabyte GA-MA770T-UD3 motherboard, NVIDIA GeForce 210, AMD Phenom II Quad Core Processor 3GHz, 4GB ram, 120GB SSD, 500GB HDD. Mint Cinnamon 17.3

User avatar
viking777
Level 14
Level 14
Posts: 5139
Joined: Mon Dec 01, 2008 11:21 am

Re: How to run commands on startup

Postby viking777 » Wed Jan 16, 2013 12:15 pm

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.
Fujitsu Lifebook AH532. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Lubuntu 13.10,Ubuntu12.10 (Unity), Mint16 (Cinnamon), Manjaro (Xfce).

User avatar
Taffman
Level 3
Level 3
Posts: 108
Joined: Fri May 06, 2011 10:51 am
Location: United Kingdom
Contact:

Re: How to run commands on startup

Postby Taffman » Wed Jan 16, 2013 1:08 pm

Nope, that didn't work either.
Linux Mint 17 Cinnamon 32-bit, Dell Dimension 9200, 4GB, 2.4GHz Core2, Radeon X1300

User avatar
viking777
Level 14
Level 14
Posts: 5139
Joined: Mon Dec 01, 2008 11:21 am

Re: How to run commands on startup

Postby viking777 » Wed Jan 16, 2013 1:26 pm

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.
Fujitsu Lifebook AH532. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Lubuntu 13.10,Ubuntu12.10 (Unity), Mint16 (Cinnamon), Manjaro (Xfce).

User avatar
Taffman
Level 3
Level 3
Posts: 108
Joined: Fri May 06, 2011 10:51 am
Location: United Kingdom
Contact:

Re: How to run commands on startup

Postby Taffman » Wed Jan 16, 2013 1:27 pm

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.
Linux Mint 17 Cinnamon 32-bit, Dell Dimension 9200, 4GB, 2.4GHz Core2, Radeon X1300

User avatar
viking777
Level 14
Level 14
Posts: 5139
Joined: Mon Dec 01, 2008 11:21 am

Re: How to run commands on startup

Postby viking777 » Wed Jan 16, 2013 1:47 pm

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.
Fujitsu Lifebook AH532. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Lubuntu 13.10,Ubuntu12.10 (Unity), Mint16 (Cinnamon), Manjaro (Xfce).

User avatar
Taffman
Level 3
Level 3
Posts: 108
Joined: Fri May 06, 2011 10:51 am
Location: United Kingdom
Contact:

Re: How to run commands on startup

Postby Taffman » Wed Jan 16, 2013 1:52 pm

Ok I'll try that. thanks for your help.
Linux Mint 17 Cinnamon 32-bit, Dell Dimension 9200, 4GB, 2.4GHz Core2, Radeon X1300

User avatar
Taffman
Level 3
Level 3
Posts: 108
Joined: Fri May 06, 2011 10:51 am
Location: United Kingdom
Contact:

Re: How to run commands on startup

Postby Taffman » Wed Feb 20, 2013 1:32 pm

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?
Linux Mint 17 Cinnamon 32-bit, Dell Dimension 9200, 4GB, 2.4GHz Core2, Radeon X1300

User avatar
bigj231
Level 5
Level 5
Posts: 790
Joined: Fri Feb 26, 2010 10:16 am
Location: Middle of Nowhere
Contact:

Re: How to run commands on startup

Postby bigj231 » Wed Feb 20, 2013 1:53 pm

Did you set the script to executable?

Code: Select all

chmod 775 yourscriptnamehere
Running on a 4-slot toaster @ 60Hz

User avatar
Taffman
Level 3
Level 3
Posts: 108
Joined: Fri May 06, 2011 10:51 am
Location: United Kingdom
Contact:

Re: How to run commands on startup

Postby Taffman » Wed Feb 20, 2013 1:57 pm

Yep tried that still doesn't work.
Linux Mint 17 Cinnamon 32-bit, Dell Dimension 9200, 4GB, 2.4GHz Core2, Radeon X1300

User avatar
johnywhy
Level 3
Level 3
Posts: 133
Joined: Tue Feb 05, 2008 9:22 pm
Contact:

Re: How to run commands on startup

Postby johnywhy » 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.
Linux Noob, but been coding for 35 years, wrote unix shell scripts in awk, lex, and sed 30 years ago.

User avatar
Habitual
Level 12
Level 12
Posts: 4096
Joined: Sun Nov 21, 2010 8:31 pm
Location: Youngstown, Ohio

Re: How to run commands on startup

Postby Habitual » Fri Jun 19, 2015 11:19 am

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
Windows assumes you're an idiot.
Linux demands proof of it.


Return to “Newbie Questions”

Who is online

Users browsing this forum: No registered users and 26 guests