I need advice for a basic SSH Ubuntu loop script..
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.
I need advice for a basic SSH Ubuntu loop script..
..that kills for 10 minutes, then back on 10 minutes,and also works with crontab. I am brand new to this so please have mercy. I don't know if any semblance of this (below) can be used, but I tried. ssh keys are installed. Thanks.
i=1
while [ "$i" -ne 0 ]
do
i=./cron5
ssh localhost
done
..that kills for 10 minutes, then back on 10 minutes,and also works with crontab. I am brand new to this so please have mercy. I don't know if any semblance of this (below) can be used, but I tried. ssh keys are installed. Thanks.
Code:
i=1
while [ "$i" -ne 0 ]
do
i=./cron5
ssh localhost
done
And your question and associated code make no sense...you want a script that "kills for 10 minutes"? What does that mean? What is your actual goal here? Because it appears as if all you're doing is trying to SSH into your local host...which is where you ALREADY ARE....so why use SSH?
..that kills for 10 minutes, then back on 10 minutes,and also works with crontab. I am brand new to this so please have mercy. I don't know if any semblance of this (below) can be used, but I tried. ssh keys are installed. Thanks.
i=1
while [ "$i" -ne 0 ]
do
i=./cron5
ssh localhost
done
Thanks Again, j.
If you have the keys in the agent, you won't need to re-enter the passphrase each time.
Code:
while true
do
timeout 600 ssh \
-i ~/.ssh/some_key.ed25519 \
-o IdentitiesOnly=yes \
-l jeffer54 \
localhost
sleep 600
done
See "man timeout", "man sleep", and the IdentitiesOnly option in "man ssh_config". Speaking of the configuration file, you might also be interested in adding some configuration options in ~/.ssh/config
Then put that in a script and call the script from cron.
Getting the keys with passphrases to work with cron is a bit more advanced because you'll have to have an agent running manually loaded with the key and point to the right socket for it in the script. Try getting the script working outside of cron first.
Apparently, the OP saw fit to come back and re-open a thread that had been closed for *SEVENTEEN YEARS* to complain about the quality of answers they received: https://www.linuxquestions.org/quest...ml#post6398793
OP, if you'd like better answers, ask better questions. Read the LQ Rules, and "Question Guidelines", about showing your own efforts. Claiming to be 'new' at scripting (when you asked about it a decade earlier), doesn't show us those efforts. You were asked what you mean by a script that "kills" for a few minutes, asked why you were trying to SSH into your local host (?), etc. But instead of coming back here to provide such details and explain things, you took that time to complain.
We aren't here to write your scripts for you, nor should we have to pry information out of you. You claim to not need 'nonsense'...neither do we.
...If you cannot answer questions without having your butt up on your shoulders, then you are in the wrong occupation. Try the N.F.L. I want to thank the one person who attempted to answer my question. P.S., the question was somewhat different as was years ago, because the question also had to do with Crontab. You know what? Block me from this sorry forum so that I don't waste my time removing MYSELF!
...If you cannot answer questions without having your butt up on your shoulders, then you are in the wrong occupation. Try the N.F.L. I want to thank the one person who attempted to answer my question. P.S., the question was somewhat different as was years ago, because the question also had to do with Crontab. You know what? Block me from this sorry forum so that I don't waste my time removing MYSELF!
jefferson.
#1 No one is here for their "occupation", this is a community. No one is paying for professional support here. There is no basis for judging anyone's occupation or fitness within that occupation.
#2 No one suggested blocking or removing you, except you.
#3 Posting a question in the "Newbie" forum when you have been on since 2013 does seem very odd. You see nothing strange or inappropriate about that? Why insult someone who pointed that out, or the forum itself? You misused the forum a bit, but that can be fixed. Why not request the post be moved to a more appropriate location?
... because the question also had to do with Crontab
Get the script working without cron first. If #5 is not a good guess, then please provide more information. More information would be good anyway, so it would be good if you could explain what you are trying to do with the script. There doesn't seem to be much point to connecting to local host for 10 minutes every 20 minutes.
Once your script is working without cron, then you can look at launching an extra agent with a designated socket for the script to refer to. Otherwise a locked down key is the way to go but for that you'd have to give a good idea about what's happening on the server end.
...If you cannot answer questions without having your butt up on your shoulders, then you are in the wrong occupation. Try the N.F.L. I want to thank the one person who attempted to answer my question. P.S., the question was somewhat different as was years ago, because the question also had to do with Crontab. You know what? Block me from this sorry forum so that I don't waste my time removing MYSELF!
Certainly CAN answer the question...if we even knew what the question WAS. You STILL have not explained your issue, what it is you're trying to accomplish, how CRON even fits into this, etc. How, exactly, do you think we'll be able to answer you when *FIVE DIFFERENT PEOPLE* have all asked for the same information???
Scheduling a job for every 10 minutes in cron is trivial...and has ZERO to do with whatever program cron executes. You were asked for more information in your first question about a bash loop, and never followed up. https://www.linuxquestions.org/quest...op-4175474340/
A simple loop is not different than it was ten years ago. And since we don't know what you mean by needing a program that 'kills' for ten minutes (kills what??) then back on ten minutes, to SSH into the machine the script is on (again, why?) to do some function....we can't give you any advice. And at this point, given your attitude, it's unlikely anyone would want to. Have your skills not progressed ANY in a decade?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.