-1

so i have around 500 servers for which i wanted to create a script that automatically login and do some trivial activity to create some logs (basically want to send logs through siem tool to check if log sending is working or not) and then automatically logoff from the server. I am planning that the script can be auto-run on the server every 15 days. trivial activity can be anything(just want to create logs). Any help how to achieve that??

EDIT

i was thinking now that stopping and starting a service in server will accomplish my need. Any help on that script. i am actually new in working in linux server. so any help is greatly appriciated.

  • You question is too broad. Please edit your question to make very clear what exactly your problem is. You can read [how to ask a good question](https://stackoverflow.com/help/how-to-ask) then edit to improve it. Thank you! – Opsse May 29 '20 at 19:27
  • Hi, i was asking help for the script content itself. On how i can login to server automatically? – darkninja10 May 31 '20 at 12:15

2 Answers2

0

This can be done by cronjobs, you can simply setup a cronjob to do the task,

0 0 15 1-12 * /path/to/your/script

This Cronjob will run at 00:00 on day-of-month 15 in every month from January through December.

  • thanks for your reply.. However i was thinking on the script part.. how to automate the login. yeah i can schedule the script to run thats ok.. but any idea on thescript itself? – darkninja10 May 31 '20 at 12:13
0

You could use cron jobs.

In the crontab file of every server you need to make an entry of the time when you wanna run the script in your case every 15 days and the location of your script file.

0 0 */15 * * /path/to/script.sh

Mind you the job would run a bit differently, as it would start at the 1st of every month, then on 16th and then finally on 31st if the month has 31 days.

  • thanks for your reply.. However i was thinking on the script part.. how to automate the login. yeah i can schedule the script to run thats ok.. but any idea on thescript itself? – darkninja10 May 31 '20 at 12:13
  • So if I understood this right! You want a script, to create scripts that is placed at a particular location in the remote server? – Joshua Amaral Jun 02 '20 at 15:47
  • yes.. help with a basic script to do any activity on server(to generate logs) which i can run without login to server every few days. – darkninja10 Jun 03 '20 at 11:42
  • I suggest you refer to this stack for getting your login done remotely. https://stackoverflow.com/questions/12202587/automatically-enter-ssh-password-with-script Post which you could simply include your commands as usual as you would in a script. – Joshua Amaral Jun 03 '20 at 16:23
  • thanks for the link. however since its production env, i dont want to install anything else (like sshpass).. instead i was thinking now that stopping and starting a service in server will accomplish my need. Any help on that.. – darkninja10 Jun 04 '20 at 16:09