[SOLVED] Need assistance writing a script to launch at startup
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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 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.
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.
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.
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 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/..."
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.
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.
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
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.