mono78v
Posts: 3
Joined: Sun Feb 04, 2018 8:25 pm

Get by password and run a cmd on startup? pls help

Sun Feb 04, 2018 8:46 pm

Hi Guys, I'm pretty new to this and looking for some advice. I've got a Pi3 with a 64bit version of stretch lite which I'm currently messing about with mining a cryptocurrency called Magi Coin (yes.. yes.. I know.. its not worth it.. I'm not going to make any money... etc...etc). I'm really only doing this as I have an interest in Crypto and want to play and learn about my new Pi.
So, this is my issue. I basically followed this tutorial https://www.novaspirit.com/2017/10/19/c ... ining-sbc/ which worked a treat. Someone then suggested I try the 64bit (unofficial) version of stretch lite which I have done and works well + gives me a better hashrate than the official 32bit version however my problem is it crashes every few days. I thought I could maybe get my Pi to reboot every night as then if it did crash it would sort its self out. I believe I can do this in crontab?? It then occurred to me that if I did that I would need to firstly log in , then start it mining again.

So I guess this is a two part question.
1) how do I get my Pi to auto log on? Maybe I can't? Could I just remove the password? But is that a bad idea? guessing compromises security?
2) when my pi boots I have to type in the following at the cmd to start it working:
$ cd wolf-m7m-cpuminer
$ ./minerd -a m7mhash -o stratum+tcp............................................................etc................

So basically, is there a way I can use crontab to reboot every day, auto log in, and then open the wolf-m7m-cpuminer directory, then finally enter the command to start mining..

Is this going to be tricky. Keep in mind I'm a total beginner. Any help would be great. I found something online about editing /etc/rc.local but getting no-where with that.

Thank You :)
Chris.

User avatar
Ace Rimmer
Posts: 104
Joined: Wed May 27, 2015 1:51 am
Location: Wit's End

Re: Get by password and run a cmd on startup? pls help

Mon Feb 05, 2018 4:08 am

Hi mono78v, to automatically run something on start up try this

Code: Select all

sudo nano /etc/profile
add your command line to the end of the file, save and exit. Every time your Pi starts up it should run your command.
To auto login from my memory I believe this can be set with raspiconfig - but I'm not sure if that's applicable in your case (stretch lite).
I'm not much more than a beginner myself :? so take everything I've said with a pinch of salt.
There must be an easier way!!!!!
I hope there is.....I haven't found it yet.

User avatar
rpdom
Posts: 15601
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Get by password and run a cmd on startup? pls help

Mon Feb 05, 2018 7:59 am

Ace Rimmer wrote:
Mon Feb 05, 2018 4:08 am
Hi mono78v, to automatically run something on start up try this

Code: Select all

sudo nano /etc/profile
add your command line to the end of the file, save and exit. Every time your Pi starts up it should run your command.
To auto login from my memory I believe this can be set with raspiconfig - but I'm not sure if that's applicable in your case (stretch lite).
I'm not much more than a beginner myself :? so take everything I've said with a pinch of salt.
Sorry Ace, but that's a really bad idea. It means that when anyone tried to log in to that Pi it will start another copy of the program and nothing else.

There are lots of ways to start a program at boot time. Creating a systemd service is one of them. Another is adding an @reboot entry to your crontab, or even adding a line to /etc/rc.local (possibly the one you were thinking of), but you have to be very careful with that one because if you get it wrong the Pi can fail to boot or will start the program and not let you do anything else.

There is documentation on how to use rc.local and crontab on the main Pi website https://www.raspberrypi.org/documentati ... c-local.md be sure to read the WARNING section.

User avatar
Ace Rimmer
Posts: 104
Joined: Wed May 27, 2015 1:51 am
Location: Wit's End

Re: Get by password and run a cmd on startup? pls help

Thu Feb 08, 2018 4:49 am

rpdom wrote:Sorry Ace, but that's a really bad idea.....
Ooops! :oops:
I used to use the rc.local method but heard it can be quite unforgiving so when I read in a book (wish I could remember which one) about using /etc/profile it sounded a lot better, hence I used it, but in my case on power-up once the script has run the Pi shuts down so there is no likelyhood of others logging in. Apologies if I misled anyone.
There must be an easier way!!!!!
I hope there is.....I haven't found it yet.

Return to “Beginners”