LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 01-23-2017, 04:10 PM   #1
rockymtngeek
LQ Newbie
 
Registered: Jan 2017
Posts: 9

Rep: Reputation: Disabled
Post Need assistance writing a script to launch at startup


I am a complete noob with Linux but I have a raspberry pi that I am trying to have launch a simple command at startup to launch websockify but cannot seem to get it to work. Here is the command I have.
noVNC/utils/launch.sh --vnc 127.0.0.1:5901 --listen 80

I have tried editing my boot script with no luck and also tried to setup a file to launch through rc.local and neither is working. If the system boots and I launch that command myself it works but this system is to run headless 200 miles from my location and I can't have it not function if the system reboots due to a power failure or other act of nature.

Last edited by rockymtngeek; 01-23-2017 at 04:48 PM.
 
Old 01-23-2017, 04:47 PM   #2
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Hello and welcome to LQ. Please note the thread you started
doesn't meet the minimum threshold that would enable us to help you.
We understand that Linux can be intimidating for new members, and we
really do want to help. That said, please understand that LQ is not a
help desk, customer service line for a product you purchased or
willing to do your homework (although we are happy to assist you with
specifics, if you show some effort of your own!). We're a 100%
volunteer organization that wants to help you help yourself.

Here are a couple tips that will enable us to help you moving forward:
  • Before posting, have you used the search function to ensure
    your question hasn't been asked before?
  • When asking a question, be
    sure to provide as many relevant details as possible. You should
    include the distribution and version you're using
    , along with hardware
    details, application version and exact error messages where
    applicable.
  • Using a descriptive title will vastly increase the
    number of members who see your thread, and therefore make a response
    significantly more likely.
  • If you're actively troubleshooting an
    issue you should also include any steps you've already taken.
  • You
    may want to include how what you are experiencing differs from what
    you expected to experience.
  • You can edit your post by clicking the
    EDIT button in the bottom right corner of your message.
If you are unwilling or unable to ask questions in a manner that
allows us to help you, it's unlikely our community will be able to
provide you a solution. Unfortunately, serial offenders who show
wanton disregard for this request after multiple pointers may be asked
to seek help elsewhere. We truly hope that isn't necessary, and assure
you Linux and Open Source are extremely rewarding and well worth the
learning curve in the long run.

Some additional reading that may help:
LQ Search
LQ Sitemap
LQ Site FAQ
How
to ask technical questions to get quality answers
 
Old 01-23-2017, 05:01 PM   #3
rockymtngeek
LQ Newbie
 
Registered: Jan 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
Wow thanks goumba. I really just need to find someone that knows how to do this type of thing to assist me briefly with a simple thing for you but is a turning into a huge obstacle for me. I appreciate your sentiment about being ignorant and this being the wrong place form me to post my questions for linux. I have read and researched for two days on this issue and I can't get it to work so I came here hoping to find someone to assist me. I will look elsewhere for assistance.

Thanks again, have a great day!
 
Old 01-23-2017, 05:21 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
If your system fails after a power failure, it is my experience,
that the sole recourse is usually re-installation, if fsck doesn't fix it.

200-mile-admin?
Don't let your alligator mouth overload your hummingbird ass.
Don't bite the hand {out} feeding you.
Code:
/path/to/noVNC/utils/launch.sh --vnc 127.0.0.1:5901 --listen 80
vs
Code:
noVNC/utils/launch.sh --vnc 127.0.0.1:5901 --listen 80
Try /path/to/ option above.

Please and Thanks go a long way.
"complete noob" at manners?

Last edited by Habitual; 01-23-2017 at 05:24 PM.
 
1 members found this post helpful.
Old 01-23-2017, 05:46 PM   #5
rockymtngeek
LQ Newbie
 
Registered: Jan 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
Thumbs up

Thanks for the tip Habitual! I had not seen that in any of my searches. I don't write code, am more of a hardware junkie.

200 miles isn't far to manage a device for sure, but when you are doing it for a favor and need remote access to fix something you won't get paid for it makes all the difference. The system has not failed nor has it been deployed. I merely need this service to run if for some reason the system (raspberry pi) were to reboot due to power outage etc. It will be running headless in a data closet and I need it to be on for me to access is all.

I appreciate any help I can get with this issue since I have been beating my head over it for the last 2 1/2 days. I finally had enough and turned somewhere to ask for help. It was just annoying to have the first reply tell me that my question did not meet the minimum threshold for this forum to assist me with and came off wrong.

I'll struggle through and maybe find an answer here or from someone locally that knows how to do this simple thing that I cannot figure out.

Thank you again!
 
Old 01-23-2017, 05:57 PM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Try putting the line in your cron. Use "crontab -e" to edit it, pick a free line, and put:
Code:
@reboot /path/to/noVNC/utils/launch.sh --vnc 127.0.0.1:5901 --listen 80
Make sure to use the full path to the launcher, your first post showed a relative path which will not work in boot scripts since they don't know where you're starting from.
 
1 members found this post helpful.
Old 01-23-2017, 06:08 PM   #7
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Quote:
Originally Posted by rockymtngeek View Post
Wow thanks goumba. I really just need to find someone that knows how to do this type of thing to assist me briefly with a simple thing for you but is a turning into a huge obstacle for me. I appreciate your sentiment about being ignorant and this being the wrong place form me to post my questions for linux. I have read and researched for two days on this issue and I can't get it to work so I came here hoping to find someone to assist me. I will look elsewhere for assistance.

Thanks again, have a great day!
Quote:
I appreciate any help I can get with this issue since I have been beating my head over it for the last 2 1/2 days. I finally had enough and turned somewhere to ask for help. It was just annoying to have the first reply tell me that my question did not meet the minimum threshold for this forum to assist me with and came off wrong.
You gave no further information, other than a Raspberry Pi. The device can run several distributions, and each of which would have their own methods for dealing with start-up. Hence the response. I even highlighted what was expected from you in this case, prompting my reason using that response.

It's actually part of a trial of sorts and your reaction has been noted. I'm sorry you had such an extreme reaction to my reply, as it was not intended to aggravate you.

Last edited by goumba; 01-23-2017 at 06:18 PM.
 
1 members found this post helpful.
Old 01-23-2017, 06:13 PM   #8
rockymtngeek
LQ Newbie
 
Registered: Jan 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
Smile

Thanks for this suicidaleggroll, by the full path you mean including the folder that noVNC is in and not the actual paths you placed: /path/to/, correct? I believe the noVNC folder is in the root. In this case would I put /root/noVNC/utils.... as the path?

Thanks!!
 
Old 01-23-2017, 06:36 PM   #9
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Quote:
Originally Posted by rockymtngeek View Post
Thanks for this suicidaleggroll, by the full path you mean including the folder that noVNC is in and not the actual paths you placed: /path/to/, correct? I believe the noVNC folder is in the root. In this case would I put /root/noVNC/utils.... as the path?

Thanks!!
That's correct. Whenever you see that here in the forums, "/path/to", you'll replace that with the actual patch in which the file is located. In your example, you are correct, you'd change eggroll's "/path/to/..." to "/root/noVNC/..."
 
1 members found this post helpful.
Old 01-23-2017, 06:41 PM   #10
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by rockymtngeek View Post
It was just annoying to have the first reply tell me that my question did not meet the minimum threshold for this forum to assist me with and came off wrong.
Well, we are sort of Hard Core.
Sorry about the alligator comment, it was a little too aggressive.

As with every forum, I'd expect a certain amount of "uneasiness" when I first join up.
But I'm a chatterbox and I know what info is usually required (I think Linux invented TMI).
New folks often simply don't know what info is relevant and what isn't, so it shouldn't be a shock
that we ask for more than "doesn't work"-type responses.

We are actually having this very discussion on this forum somewhere. Seriously.
One member wrote a script.
 
1 members found this post helpful.
Old 01-23-2017, 07:18 PM   #11
rockymtngeek
LQ Newbie
 
Registered: Jan 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
Thanks for clarifying that goumba. I ran the command in crontab -e as stated with the /root/noVNC/... but nogo. I also read somewhere afterwards that scheduling a task with chrontab like that does not guarantee it will start after the user account has logged in which may be the issue as to why that didn't work. Also found reference to having this run after the network is up: "network-online.target is a target that actively waits until the nework is "up", where the definition of "up" is defined by the network management software". I just don't know how to implement that either.

For a more detailed explanation of my conundrum here it is:

I have a raspberry pi 3 model B. I installed Debian jesse (latest version) to this and decided to use Dataplicity's remote connection service as a solution for me to have remote access to this pi. I need to install this at a remote site for accessing an internet modem and AP at a hotel in a small town that I setup for a friend two years ago. Every once in a while the network goes down and their guests cannot access the wifi. There is not hardwired PC onsite that I can setup remote access on and this seemed like it was the ticket for me to have 24/7 access. They had an issue last week that I was able to resolve because someone there let me remote to their laptop and work from it, the issue was there was an infected device on the network causing the AP to cycle continuously. Once I blocked that mac address everything was golden again.

On this pi, I installed Debian jesse, and followed the instructions for Dataplicity here: https://docs.dataplicity.com/docs/ma...ce-for-your-pi

The only issue is that if the pi reboots for some reason, power outage, cable comes unplugged etc., I can't open their wormhole to access the desktop of the pi. I can get to the terminal through their site but cannot call on that command to enable the service even switching so SU via the terminal.

The instructions on their site are great and I was able to get this setup and working. The last part of this section of instructions is what falls short:
"Launch websockify
Code:
cd noVNC
./utils/launch.sh --vnc 127.0.0.1:5901 --listen 80
Port 80 not available
If you've run one of the other examples which involved installing the NGINX web server, you might get an error which indicates port 80 is already in use. You'll first need to make this port available to websockify. The easiest way to do this is to stop NGINX by typing service nginx stop at the terminal.
You can quit the NoVNC mini-webserver with Ctrl-C anytime, but you'll need to restart it by re-running launch.sh as above (or you can build your own init script for it!). Your Pi is now ready."

What they left out was the instructions to: "build your own init script for it".

If I am at the pi with a kbd & mouse, I can launch the command and the service works great through their online portal, however if I power off the pi, and take it to the site I will need to have a tv, kbd and mouse to get it running again which is not helpful. I spoke with the someone at Dataplicity a few times this morning and told them what issues I was having with their script. They did not get back to me after several emails without a solution. I did more searching for various solutions online and finally turned somewhere where i could talk to other linux pros that might be able to assist.

I apologize for the lengthy response but this is my issue in its entirety - I think
 
Old 01-23-2017, 08:14 PM   #12
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by rockymtngeek View Post
I ran the command in crontab -e as stated with the /root/noVNC/... but nogo.
That's not very helpful. What did you "run"? What do you mean by "nogo"? We need details. Exactly what steps did you take? What happened that you didn't expect? What didn't happen that you did expect?

You don't "run" anything in crontab. The crontab is a text file that contains a set of commands you want to execute at specific times or under specific conditions. You use "@reboot" to tell cron that you want the following command to be run when you boot. Afterwords you'll need to reboot in order for anything to happen.

Please post the output of "crontab -l", that will display the current contents of your crontab, which will show if you made any typographical errors. You may also want to stick "&> $HOME/noVNC.out" to the end of the command to log any output information to a file for review.

Last edited by suicidaleggroll; 01-23-2017 at 08:16 PM.
 
1 members found this post helpful.
Old 01-23-2017, 09:28 PM   #13
rockymtngeek
LQ Newbie
 
Registered: Jan 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
I ran "crontab -e" and added this line as previously mentioned:
Code:
/root/noVNC/utils/launch.sh --vnc 127.0.0.1:5901 --listen 80
I then pressed ctrl+x to save the file, Y to accept it and then enter to save & exit. I rebooted the pi and tested the connection at Dataplicity once it saw my pi was back online however, the noVNC service would could not connect to the pi because the service was not running. The "nogo" comment was not a complete explanation of the situation I agree, my military background comes out too often in explanation sometimes.

Your reply was very helpful including the "crontab -l" command. I was unaware of that and assumed I had entered and saved the command successfully. I ran the "crontab -l" command and found that nothing had been saved from my first try. I went through the steps once again and after saving it, verified that it saved that command before restarting the pi. This time everything worked as I need it to and I can access the pi through the Dataplicity web portal, even after a reboot and after a complete power off and leaving it disconnected from power for a while.

Thank you for the additional option to create a log file. I am going to add that as well for future diagnostics.

Thank you all for your help with this issue today!

I'll make my own guide for setting up a pi like this in case I need to do it again in the future.
 
Old 01-23-2017, 09:33 PM   #14
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Quote:
Originally Posted by rockymtngeek View Post
I ran "crontab -e" and added this line as previously mentioned:
Code:
/root/noVNC/utils/launch.sh --vnc 127.0.0.1:5901 --listen 80
I then pressed ctrl+x to save the file, Y to accept it and then enter to save & exit.
You forgot the @reboot at the beginning of the line. Exactly as eggroll stated previously:

Code:
@reboot /path/to/noVNC/utils/launch.sh --vnc 127.0.0.1:5901 --listen 80
Now that you've specified Jessie, you could looking into writing a systemD unit, that's where your network target that you mentioned comes in. This is likely the easier route.
 
1 members found this post helpful.
Old 01-23-2017, 09:36 PM   #15
rockymtngeek
LQ Newbie
 
Registered: Jan 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
I did leave that out in my reply but did enter it as such into crontab -e @reboot/root/noVNC.....etc. I was so excited that it finally worked that I missed typing that into the explanation.
 
  


Reply



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
How to launch PHP script at startup on RHEL? sneakyimp Linux - Newbie 3 05-15-2013 06:55 PM
[SOLVED] how to launch different application on startup julybrownie Linux - Newbie 2 08-15-2012 12:10 PM
Howto launch script at startup sendas4 Linux - Newbie 2 03-10-2005 10:51 AM
External DVD writing - assistance please neocookie Debian 0 02-15-2005 06:46 AM
Have Firefox Launch X on startup Johnathan4 Linux - Software 1 02-12-2005 10:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:25 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
Open Source Consulting | Domain Registration