A guide to Linux commands to create a file using SSH, then set the CronJob to run the file on a ReadyNas running Linux

Hi Experts,

I really need some help in the Linux world.

I have a Netgear ReadyNas that operates a Linux OS.
I would like to set a CronJob for the Bittorent client on the box, however I don't know how to do it.
The scripts etc are in this forum
http://www.readynas.com/forum/viewtopic.php?f=36&t=16866&st=0&sk=t&sd=a&start=30

If you could tell me how, once I have logged into SSH to create the scripts and then set the CronJob I would really appreciate it.

Cheers

C
LVL 1
Craig LambieAsked:
Who is Participating?

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

x
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.

omarfaridCommented:
to create script, you need to either copy with scp or sftp, or create using editor like vi.

OR

use

cat  "#!/bin/sh" > /usr/share/bittorrent/bt-throttle-down.sh
cat  '/usr/bin/wget -q -t 1 -O /dev/null http://localhost:8080/api/app-settings-set?auto_bandwidth_management="0"' >> /usr/share/bittorrent/bt-throttle-down.sh
cat  '/usr/bin/wget -q -t 1 -O /dev/null http://localhost:8080/api/app-settings-set?max_dl_rate="1024"' >> /usr/share/bittorrent/bt-throttle-down.sh
cat  '/usr/bin/wget -q -t 1 -O /dev/null http://localhost:8080/api/app-settings-set?max_ul_rate="1024"' >> /usr/share/bittorrent/bt-throttle-down.sh
cat  '/usr/bin/wget -q -t 1 -O /dev/null http://localhost:8080/api/app-settings-set?max_ul_rate_seed="1024"' >> /usr/share/bittorrent/bt-throttle-down.sh

similarly,you can do other scripts

for crontab:

crontab -l > mycron
cat '# Throttle the bittorrent manager according to time of day' >> mycron
cat '# Throttle down at 3:45pm, 15 minutes before ISP's peak usage period' >> mycron
cat '43 15 * * *     /usr/share/bittorrent/bt-throttle-down.sh' >> mycron
cat '# Throttle up at a quarter past midnight, 15 minutes after ISP's peak usage period' >> mycron
cat '15 00 * * *     /usr/share/bittorrent/bt-throttle-up.sh' >> mycron

crontab mycron
0
Craig LambieAuthor Commented:
Sorry, I should of mentioned....
I have no idea how to do anything in the world of Linux, so command by command is almost required to get me started at least.

Thanks
0
omarfaridCommented:
you need to login to the system , then from command line, copy and paste commands given earlier:

cat  "#!/bin/sh" > /usr/share/bittorrent/bt-throttle-down.sh
cat  '/usr/bin/wget -q -t 1 -O /dev/null http://localhost:8080/api/app-settings-set?auto_bandwidth_management="0"' >> /usr/share/bittorrent/bt-throttle-down.sh
cat  '/usr/bin/wget -q -t 1 -O /dev/null http://localhost:8080/api/app-settings-set?max_dl_rate="1024"' >> /usr/share/bittorrent/bt-throttle-down.sh
cat  '/usr/bin/wget -q -t 1 -O /dev/null http://localhost:8080/api/app-settings-set?max_ul_rate="1024"' >> /usr/share/bittorrent/bt-throttle-down.sh
cat  '/usr/bin/wget -q -t 1 -O /dev/null http://localhost:8080/api/app-settings-set?max_ul_rate_seed="1024"' >> /usr/share/bittorrent/bt-throttle-down.sh


crontab -l > mycron
cat '# Throttle the bittorrent manager according to time of day' >> mycron
cat '# Throttle down at 3:45pm, 15 minutes before ISP's peak usage period' >> mycron
cat '43 15 * * *     /usr/share/bittorrent/bt-throttle-down.sh' >> mycron
cat '# Throttle up at a quarter past midnight, 15 minutes after ISP's peak usage period' >> mycron
cat '15 00 * * *     /usr/share/bittorrent/bt-throttle-up.sh' >> mycron


0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Craig LambieAuthor Commented:
Here is the results from copy and pasting

NASShared:~# cat  "#!/bin/sh" > /usr/share/bittorrent/bt-throttle-down.sh
-bash: !/bin/sh" > /usr/share/bittorrent/bt-throttle-down.sh: event not found
NASShared:~# /usr/share/bittorrent/bt-throttle-down.sh
-bash: /usr/share/bittorrent/bt-throttle-down.sh: No such file or directory
NASShared:~#  /usr/share/bittorrent/bt-throttle-down.sh
-bash: /usr/share/bittorrent/bt-throttle-down.sh: No such file or directory
0
omarfaridCommented:
do you have the directory /usr/share/bittorrent already created? if not then you may create with

mkdir /usr/share/bittorrent
0
Craig LambieAuthor Commented:
ok, I have tried a couple of things now...

I think maybe the SSH program I am using doesn't work properly?
I am using this ZOC program for Windows to connect
http://www.emtec.com/zoc/index.html

Results:
NASShared:~# mkdir /usr/share/bittorrent
mkdir: cannot create directory `/usr/share/bittorrent': File exists
NASShared:~#
NASShared:~# cat  "#!/bin/sh" > /usr/share/bittorrent/bt-throttle-down.sh
-bash: !/bin/sh" > /usr/share/bittorrent/bt-throttle-down.sh: event not found
NASShared:~#
0
Craig LambieAuthor Commented:
I also tried to go into VI in this ZOC terminal and when I press ESC and then hit q it says

~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
'q' is not implemented                                                          
0
omarfaridCommented:
if you are going to use vi, then the commands are

a to apend or i to insert
then put the text you want
then hit ESC key
then run :wq

If you face difficulty in using vi, then crate the file (text) on another system then scp or sftp it to the remote system
0
Craig LambieAuthor Commented:
ok, I have created the files in notepad and copied them into a share.

I then managed to use the
cd
ls
cp
commands to navigate around the SSH and get the files into the dir in question.

Now I went to add the next step of editting the CronTab I get this reply from the SSH
NASShared:/# crontab -l
no crontab for root
AND
NASShared:/# crontab -l > mycron
no crontab for root

So... do I need to create this somehow?
I was under the understanding that this just worked... but it doesn't seem to be so.?

C
0
Craig LambieAuthor Commented:
ok... now I have navigated to /etc/

then used vi, which I worked out I was missing the ":" in front of the q to make is quit correctly to edit this crontab file in the /etc/ dir

it now reads - Attached Code Snippet.

I hope this works... Will check it tonight and get back to you in the morning.

Cheers

C
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file.
# This file also has a username field, that none of the other crontabs do.
 
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
# m h dom mon dow user  command
25 6    * * *   root    test -e /usr/sbin/anacron || nice run-parts --report /et47 6    * * 7   root    test -e /usr/sbin/anacron || nice run-parts --report /et52 6    1 * *   root    test -e /usr/sbin/anacron || nice run-parts --report /et# Throttle the bittorrent manager according to time of day' >> mycron
# Throttle down at midday ' >> mycron
00 12 * * *     /usr/share/bittorrent/bt-throttle-down.sh' >> mycron
# Throttle up at 2am ISP's peak usage period' >> mycron
00 02 * * *     /usr/share/bittorrent/bt-throttle-up.sh' >> mycron
 
#
   

Open in new window

0
omarfaridCommented:
it seams that you have a limited version of linux.

Since you did not have any crontab job for root already scheduled , then you could simply create mycron file which basically a temp file just to create the crontab jobs schedules
0
Craig LambieAuthor Commented:
ok,

so.... where should this file go?
Do I just simply put the cronjob info in it as per above snippet?

0
Craig LambieAuthor Commented:
Ok...

I have been playing around with this and I have not got much of a result

NASShared:/etc# crontab -l
no crontab for root
NASShared:/etc# crontab -e
no crontab for root - using an empty one
editor: applet not found
crontab: "/usr/bin/editor" exited with status 1
NASShared:/etc# crontab -l
no crontab for root  

How would I set up the Cron Job?
I tried this command in /etc
vi mycron

edit the file, then ended with :wq
but the file didn't appear?

Should I create it somewhere else, then try to use it?
Where should it go?
How do I make it scheduled?

Thanks
0
omarfaridCommented:
try

EDITOR=vi
export EDITOR

crontab -e

Then you add the schedules you want, then save and quit. If you do not know how to use vi, then you please create a temp file e.g. cronjobs (may be on some other system then copy to linux systtem) then run

crontab cronjobs

By the way you can add the job schedule to /etc/crontab but not both ways to avoid double work.
0

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
Craig LambieAuthor Commented:
Ok,
Did as you suggested, which made crontab -e work.

But then I put the crontab jobs in with vi, on getting out of the program with :wq (save) it suggested below.

So I went with the other option.
I with the other option... made a file, attached called cronjobs.txt
then changed it to just cronjobs

NASShared:/media# ls
BitTorrent  bt-throttle-down.sh  bt-throttle-up.sh  cronjobs  mycron
NASShared:/media# crontab cronjobs  

no errors reported, so will see what happens overnight

~
~
~
~
~
~
~
~
~
~
~
~
crontab: installing new crontab
"/tmp/crontab.XXXXacW1Z4":1: bad month
errors in crontab file, can't install.
Do you want to retry the same edit? n
crontab: edits left in /tmp/crontab.XXXXacW1Z4 

Open in new window

cronjobs.txt
0
Craig LambieAuthor Commented:
Ok... the cronjob doesn't appear to be running, so had a play with some commands, here are the results, any ideas?
Points Increased to accomodate long... long .. question
NASShared:~# /usr/share/bittorrent/bt-throttle-down.sh
-bash: /usr/share/bittorrent/bt-throttle-down.sh: Permission denied
NASShared:~# NASShared:~# crontab -l
-bash: NASShared:~#: command not found
NASShared:~# crontab -l
# Throttle down at midday ' >> mycron
00 12 * * *     /usr/share/bittorrent/bt-throttle-down.sh' >> mycron
# Throttle up at 2am ISP's peak usage period' >> mycron
00 02 * * *     /usr/share/bittorrent/bt-throttle-up.sh' >> mycron
 NASShared:~# cd /usr/share/bittorrent/
NASShared:/usr/share/bittorrent# ls
bin  bt-throttle-down.sh  bt-throttle-up.sh  dnacache  start_bt.sh  webui
NASShared:/usr/share/bittorrent# bt-throttle-down.sh
-bash: bt-throttle-down.sh: command not found     

Open in new window

0
Craig LambieAuthor Commented:
any ideas?
0
Craig LambieAuthor Commented:
Do you have anymore to add to this job?
I would like to move on this, but I am not getting much response?

C
0
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
Server Software

From novice to tech pro — start learning today.