Scheduled Task Raspberry Pi

Hello Internet!

I have a few usb miners running on a raspberry pi.

this is what i'd like to achieve.

  1. automatically reboot pi every... say... 4 hours
[list=2]when pi starts up - start screen session and run cmd: sudo /home/pi/git/vthoang/cgminer/cgminer -o stratum+tcp:// -u zbw123.worker1 -p x --gekko-2pac-freq 150 [/list]

there are a few examples of this being done that i can find online but they all seem to assume a certain level of linux understanding and the truth is i know absolutely nothing about linux. i can follow instructions to the letter but thats about it! :-)

i have bought a book "for dummies" but i'm not finding the answers i need. If it were windows i'd wright a start.bat file i guess.

I downloaded a GUI for crontab which helps you manage scheduled tasks but of course it requires the appropriate files to exist already so that i may run....
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nociSoftware EngineerCommented:
A   .BAT file is called a script on linux/unix.
A script can be written in a variety of languages perl, python, .. etc. for your purpose then command shell is easiest.. a bash script.
So put your command line in such a script:

sudo /home/pi/git/vthoang/cgminer/cgminer -o stratum+tcp:// -u zbw123.worker1 -p x --gekko-2pac-freq 150

Open in new window

Now if you want to start this regularly use cron...
install cron  and use crontab to add an entry...
Not sure why you need the reboot etc.  In Unix most command don't need to have the screen active... most stuff can be done through remote logon through ssh (putty from Windows)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bede123Author Commented:
hi noci, thanks for the quick reply.

where should be the best place to store file?

also with regard to the reboot... what seems to happen is every so often one of the usb miners will switch off/freeze and if left unnoticed this causes pi to freeze meaning i can no longer VNC into it. thats why i though if i simply force a reboot every so often it will keep everything alive and fresh
nociSoftware EngineerCommented:
can be anywhere is you can still find it...
/usr/local/bin   would be a good place if you want to call it as a command. (in that case you may drop the .sh extension and name it just miner).

Also then make the file executable
 chmod +x

Open in new window

 if you want to call it directly in stead of bash

Be aware that in cron you may need to prefix all commands with the right path....  (/usr/local/bin/..  f.e.).
But what would cause the freeze...., if the pi has issues with power f.e. (too much current drawn) then brownout may cause it to halt...
in that case a scheduled reboot would fail as well.
Be sure you have enough power for USB devices. 1A PSU might not be sufficient. possibly feed the USB devices through a powered HUB.

VNC is a rather huge program...,  try putty /ssh instead. You will get a command line but with a lot less effort.
(VNC will also cause the GPU to draw extra power...).
bede123Author Commented:
yes i'm def using a powered hub.

this is what i have so far:

i called in and saved it to /home/pi/git/vthoang/cgminer


sudo /home/pi/git/vthoang/cgminer/cgminer -o stratum+tcp:// -u zbw123.worker1 -p x --gekko-2pac-freq 200

Open in new window

then i adjusted this:

nano ~/.config/lxsession/LXDE-pi/autostart

Added this line to the end of the file:


so that the terminal automatically opens up  on reboot.

but the cron job doesn't appear to start. the terminal opens up but thats it....
nociSoftware EngineerCommented:
The problem is this commands isn't a graphical command.
lxterminal won't know what to do....
You could help lxterminal by telling it what you want:
for cron you need another tool the cron daemon.., and that runs in the background, it wiil (& should) never show up on the foreground..
(and runs timed jobs in the background)...
The LXDE autostart will run when LXDE starts...
replace your command with
@lxterminal -e /the/path/to/

to execute the lxterminal program and have THAT execute your miner.

btw. You could check with
ps | grep miner 

Open in new window

if your miner is running from any terminal.
bede123Author Commented:
thanks for the reply. was just about to type out my progress so far an then you posted this message.

i have just got it to work by doing the following:

show hidden files
open .bashrc
locate the very bottom and paste:


right click on and allow anybody to run the file under permissions.

and hey presto it works.


I will also try pasting the cmd after @lxterminal to confirm that as well.

now all i need to do is to have the rasp pi automatically reboot every so often and we're away!
bede123Author Commented:

@lxterminal -e path/to/
nociSoftware EngineerCommented:
.bashrc will start the miner on ANY shell access, not just when you want it... (f.e. when you login with putty/ssh).
bede123Author Commented:
Yes I discovered that so I have changed it to what you suggested.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.