LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-07-2013, 05:55 PM   #1
Ahsaniqbalkmc
LQ Newbie
 
Registered: Aug 2013
Posts: 5

Rep: Reputation: Disabled
Best method for automatic command execution every time a system boots up


I have a raspberry pi which I use without a monitor. I boot it up, connect to it via SSH, and then start a VNCserver on it. I have to do it every time I start the device or reboot it.

I would like to automate the process. Like in windows, I would add the vncserver to startup programs and it would automatically start every time the system boots up.

I need to know how can I do this on raspbian wheezy. I tried to find a solution by googling but I wasn't able to successfully achieve what I wanted. Some websites talked about /etc/rc.local, some about crontab etc etc.

As I am new to linux so I don't understand them. So I would love to know what is the best method to do it and then I would like to go deeper and understand the procedure.

Thankx
 
Old 08-07-2013, 05:57 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Add it to /etc/rc.local. Commands in this file will be executed after all other init scripts have completed.
 
1 members found this post helpful.
Old 08-07-2013, 08:33 PM   #3
Ahsaniqbalkmc
LQ Newbie
 
Registered: Aug 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks @Kustom42

I added the following line to the /etc/rc.local file before the "exit 0" and it worked like a charm

sudo vncserver :1 -geometry 1340x74 -depth -16

Taking advantage of this discussion, I would like to ask you "What is rc.local file?". I don't have much experience with Linux machines so I have to ask this noob question.
 
Old 08-08-2013, 07:43 PM   #4
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
The previous post basically explains it.

rc are run level scripts, you have a bunch of them that each service creates so it starts on boot. the rc.local is for custom commands and such you want executed after all the other rc scripts are.


do some ls'ing on /etc/rc5.d/


http://www.tldp.org/LDP/sag/html/run-levels-intro.html
 
Old 08-08-2013, 07:59 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,263

Rep: Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329
Some articles
https://en.wikipedia.org/wiki/Linux_startup_process
http://luv.asn.au/overheads/linux-startup.html
 
Old 08-13-2013, 04:17 PM   #6
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,128

Rep: Reputation: 1546Reputation: 1546Reputation: 1546Reputation: 1546Reputation: 1546Reputation: 1546Reputation: 1546Reputation: 1546Reputation: 1546Reputation: 1546Reputation: 1546
I have always lamented that rc.local was not named rc.last

(RC = Run Control, IYI)
 
Old 08-14-2013, 06:58 AM   #7
Ahsaniqbalkmc
LQ Newbie
 
Registered: Aug 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks @Kustom42, @chrism01 for the helpful links... I didn't grasp all of what was in those articles but at least now I know more than before reading those...
 
Old 08-14-2013, 07:52 AM   #8
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
Quote:
Originally Posted by Ahsaniqbalkmc View Post
Thanks @Kustom42, @chrism01 for the helpful links... I didn't grasp all of what was in those articles but at least now I know more than before reading those...
and thats the key. now that you have some knowledge you can experiment, fail, experiment some more, and succeed, or at the very least ask more detailed questions.
 
Old 08-14-2013, 08:47 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,263

Rep: Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329Reputation: 2329
lleb++ ... couldn't have put it better myself
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
command execution time minil Programming 10 08-20-2010 05:59 PM
System message getting printed after every command execution mohit052 Linux - Server 16 03-10-2010 01:27 AM
New user; I can't get to GUI, boots to command line each time John S. Linux - Laptop and Netbook 13 07-21-2007 01:00 AM
Automated execution of a command on a remote system via SSH GUIPenguin Linux - General 1 03-01-2006 12:23 AM
Automatic execution of a command after login openart Linux - Newbie 5 10-29-2004 02:44 AM


All times are GMT -5. The time now is 01:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration