First i would just like to point out, i know very little about this subject matter. Okay, now that that is out of the way.
I am trying to setup a batch script to ssh to a list of IP's (about 50) and create a simple cron job to reboot the box it connects to every 24 hours at midnight local time.
I already create the cron job in VI, but i have no idea how to make this batch script work. I have tried to piece meal a batch together but, have had zero luck. Lastly i think i should mention that i am making the batch file on a windows box, and sshing to a Linux shell. If their is anything you guys need let me know and i will try to supply it.
Thanks in advance!
Edit: for clarity
May this be useful?
HERE
Inside the "commands.txt used in the script i linked to:
shutdown -r -t sec 0 Rebooting
exit
Related
Hey guys I have troubles writing batch file, could you help me with it? I want to write bat file that executes occasionally(every 2-3 hours for instance). I want to accomplish something like this:
cd D:\Repositories\myRepo
git checkout master
git pull
cd D:\Repositories\myRepo2
git checkout master
git pull
I know that in unix based OS there is command that there is inotifywatch command that can help me execute that file over period but I don't know what can do this in Windows. Could you help me? Also these six lines that I wrote doesn't seem to be working for some reason? Is there any chance that I execute them one after another because I am not sure if they are waiting one another right now..
I am having an issue with the new version of Tableau 9.0.1 where I need to run tabadmin cleanup daily or else several gigabites of data will be stored on my server slowing things down and often leading to crashes if not taken care of regularly.
Can someone help me write a batch file script to accomplish the following commands that can be run every morning using task scheduler to avoid future issues?
Tableau is said to be releasing a patch fix from this issue in 9.1.0 but it is an issue we are dealing with currently.
Scripts to run:
cd C:\Program Files\Tableau\Tableau Server\9.0\bin
tabadmin cleanup
I would appreciate anyone's help who is familiar with writing batch files.
Thank you,
Connor
what if you put in a sleep in it and put in in the startup folder?
so when the server starts it would run to file and in the file you can have sleep X amount of seconds then it can run them. then if you have that in a loop you can have it clean every say 12 hours or 24 hours. then if you lose power or a restart it will just run again.
Good day,
I have written a java code which pulls Active Directory user details.
However I need to schedule this program to run daily with a batch script possibly.
I do not know how to perform this.
Thanks,
Patrick
I think you are looking for the crontab command: http://en.wikipedia.org/wiki/Cron. It's not the easiest syntax to work with but it will run a command with a defined frequency...
Long story short... we have multiple servers which we run perflog monitoring on every night. My job is to convert these logs to .csv format and send them to my e-mail.
This bit it already automated via a .sh script an ex-employee wrote.
What I want automated is to run a batch job after the perfmon logging to look at a specific folder and find the latest .blg file and run the sh script on it (the script is called upload) so that I don't have to log in to each server and do it manually.
e.g.
upload myInitials cd /cygdrive/someLocation/logs/$latestFile$.blg
myInitials and the location can be hard-coded... I just wouldn't know how to find the latest file in the folder and automate it all via a batch file.
Any pointers would be very helpful!
# Jeremy:
Sorry, I probably should have mentioned in my question that the servers are running 2003 and 2008.
I don't think it would be absolutely necessary to register a change notification on the folder - If the log runs from noon till 7 in the morning, the script will run immediately after (you can set a script to run after a perfmon log has finished in log properties) so the log will almost definitely be the latest file in the folder anyway.
Like I said, I already have a .sh file in place to convert to csv and send to my e-mail, I just need to incorporate it into a batch file so that instead of me going to each of the servers and opening up cygwin and typing upload xx /cygdrive/location/logs/xyz.blg, I can have it automated to run straight after the log has finished without me having to RDC into it.
Thanks for the input!
If you have a Shell script and you job is to call the shell script from a windows batch file then this will work.This assumes the cygwin is installed in C:
Contents of start_cyg.bat
#echo off
set PATH=%PATH%:"C:\Cygwin\bin"
rem bash --login -i
bash "/cygdrive/d/cyg.sh"
Contents of cyg.sh
#!/bin/bash
TAIL=`ls -lrt | tail -1`
echo "TAIL:$TAIL"
If you call start_cyg.bat from windows command prompt you can get the output of the cyg.sh in the console
for getting newest file in a directory, ls -1tr | tail -1 should work.
First, I don't know if it would meet your requirements, but the Windows Task Scheduler 2 in Vista+ is very robust and can trigger an event even based on log entries. However, extraction and parsing of that log entry may require some scripting, and might have concurrency issues, even if that log entry did indicate the last used process. Chances are none of this is helpful, but just throwing it out there.
Programatically, it would be simple as you can register a change notification on a folder. When a change occurs, you go find the latest file. Then launch the batch file to launch your shell script, or whatever your desired sequence may be.
I think cygwin may even support change notification events via scripting, though I'm unsure. I believe there are linux extensions for this, but I may be wrong.
If it were me, I'd just write a little C++ app to do whatever I wanted.. but for you maybe any (or more likely none) of the above helps ;o.
I have a simple batch file as seen below that should extract a zip file to the root of E:. The zip file is valid and I can run the batch file from the command line just fine.
Instead of completing the task, it continues to inform me that the Status is "Running". The problem is, it is not running and the file never gets unzipped.
The task is running as a Domain Admin that has been specifically added as an Admin on the box.
Are there any known problems with using zip files in Scheduled Tasks. I actually have this same problem on 3 out of the 12 boxes this task runs on, but there is no rhyme nor reason as to why some servers work, and others don't.
Any ideas on how to debug what is going on, or a solution would be very helpful.
Here is the batch file I'm attempting to run.
SET RootPath=E:
SET WinzipLocation=E:\Program Files\WinZip
"%WinzipLocation%\winzip32" -e -o %CD%\TestZipFile.zip %RootPath%
Try to use the WinZip Command Line Support Add-on.
what if you use 7-zip in command line?
I realized after posting that the "bad" servers were all 64-bit. I was running the 32-bit version of winzip. Since the company I work for doesn't see the benefit in purchasing any software, I had no other option but to starting using 7-zip. I have not tested for any performance increases or hits, but I do not that it works, regardless of the environment.
Thanks for the answers, but it looks like without the 64-bit version of winzip....i have no other options.