1

I have Machine-1 and Machine-2 connected via LAN. I want to create a program that see if number of jobs scheduled in Machine-1 exceeds certain limit then to schedule upcoming jobs in Machine-2 so to avoid overhead from single machine. Both Machines has Ubuntu OS.

I already can count the number of job scheduled in machine-1. Just not getting the way how could i install job in another machine.

How can i achieve this setup?

Is it possible to be done via TELNET? Or Any suggestions??

Any help/hint/solution will be appreciated.

Best Regards, MD Danish

Trevor
  • 1,111
  • 2
  • 18
  • 30
MD Danish
  • 179
  • 1
  • 10

2 Answers2

1

What I would do is create a script on Machine-2 which counts the jobs (you seem to have already done that). Then, from Machine-1, call that scripts via SSH and do something useful with the results.

Example script on Machine-1:

!#/bin/bash result=`ssh user@machine2 /data/scripts/countJobs.sh` ...do something with result...

Tammert
  • 196
  • 6
  • I need to edit my question, I am taking database help in intermediate, I am able to install and count the jobs of same machine but not another machine... – MD Danish Dec 07 '15 at 17:41
  • Could you explain how you count the jobs on Machine-2 then? – Tammert Dec 07 '15 at 17:43
  • Yes correct! Can we send the parameter in remote call? In this case better i will send the cron path as a parameter and upload the script file? – MD Danish Dec 07 '15 at 17:48
  • Sure, adding parameters would just be `ssh user@machine2 /data/scripts/countJobs.sh param1 param2` etc... – Tammert Dec 07 '15 at 17:49
  • I have one centralized database from there I can monitor the number of cron jobs scheduled for that particular machine. Also By Counting the number of new lines present in Crontab. – MD Danish Dec 07 '15 at 17:50
  • Then How can i upload the file to that machine via such kind of remote call? – MD Danish Dec 07 '15 at 17:51
  • What file do you want to upload? – Tammert Dec 07 '15 at 17:51
  • I'm still unsure what you're referring to. Can you please describe the transfer of the file (from Machine-1 to Machine-2? The other way around?) and why it is needed? – Tammert Dec 07 '15 at 18:01
  • I have written crawler algorithm to search in web for the links. Every time Script used to assign a couple of links to each spider and install the spider as cron job. This way my script is single machine centric. But now I am 90% clear with what to do next... Your help has made me clear... Tammert – MD Danish Dec 07 '15 at 18:05
  • Awesome :). Good luck! – Tammert Dec 07 '15 at 18:06
  • I am just wondering if i can upload via scp but without manual entering password? – MD Danish Dec 07 '15 at 18:07
  • You have to set up SSH keys on both machines. See the following link for a tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2 – Tammert Dec 07 '15 at 18:08
  • No problem! If my answer helped, please mark it as the answer to the question :). – Tammert Dec 07 '15 at 18:12
0

You can make some remote call using ssh (telnet is not recommended as it's not secure). Just type ssh login@host [command]. To play with cron I use (on Fedora and Centos) crontab -e .

jaroslawj
  • 462
  • 2
  • 12