Batch Copy Logs From Server At Multiple Intervals Using Task Scheduler

I came across a situation where a vendor wanted logs files from a server at around 2am in the morning to troubleshoot why an application wasn’t sending a specific email at that time. Problem was, I wasn’t planning on being up at that early in the morning to grab log files and I didn’t know exactly what time it was supposed to send it. The time was usually around 1:30am but sometimes, when it worked, I’ve seen it sent at 4:30am.

So the plan was to come up with a simple batch file to handle the copying of the logs at every hour between 11PM and 5AM to my local Win 7 desktop,

This required a few things:

  1. A batch file that would a) make a directory based on the current time b) copy the files into that directory
  2. A task to run the batch file, triggered at every hour between 11pm and 5am.
  3. Access to the server where the logs are kept

 

Batch File

My batch file consisted of  the following:

@echo off
SET datestmp=%date:~-4,4%%date:~-10,2%%date:~-7,2%
SET HOUR= %time:~-11,2%
CALL :TRIM %HOUR%
SET timestmp=%HOUR%_%time:~-8,2%
MKDIR logs\servername\%datestmp%_%timestmp%
@echo on
COPY \\servername\logs\email.log  logs\servername\%datestmp%_%timestmp%\ @echo off
GOTO EOF
:TRIM
SET HOUR=%*
:EOF

 

The above batch file first gets the date and time, formats it, and creates a directory with the date/time as part of the directory name. So if the date and time was 6/09/15 and the time was 2am, the directory would be called “20150609_2_00”

Then it takes the email.log file from the \\servername\logs\ folder and copies it to a local folder on my machine called logs\servername\20150609_2_00\, which would be relative to where the batch file is run from.

I named the above batch file copylogs.bat and saved it on my local desktop under the C:\temp folder.

I ran the batch file to make sure it works and instead it failed! The reason being, the batch file ran under my desktop login account. I have a separate admin login for the server. So I mapped to the server using my admin login first. With that connection being made, I reran the batch file, and sure enough, it worked.

Next up was creating the tasks to run the batch at certain intervals…

Task Scheduler

1. Start by Creating a Basic Task:

basic task

2. Give the task a name:

task name

3. Set your trigger. In my case I’m setting to “One time” and will give it a specific time to start (probably about 20 minutes into the future so that I can test to see if it will run properly). Later, I will schedule it to run at particular times throughout the night.

trigger

4. Set your action. In My case I’m starting a program (my batch file):

action

5. Here’s where things start to get tricky.

Since it’s a batch file, the Program/script I’m running is cmd (command prompt). The Additional arguments will be:

/k start “” “c:\temp\copylogs.bat”

And it’s starting in c:\temp (no quotes).

start

6. After saving the task, one last thing I had to do was go back, edit it, and Change User or Group, so that it ran under my server admin account, and Run whether I was logged in or not, saving my password.

final

After I finished, and tested it successfully, I went back and edited the task, adding more Triggers:

more triggers

That’s it! Hopefully someone else will find this useful.

 

 

Internet Explorer 8 – Does Not Remember Password

Problem: Internet Explorer 8 won’t remember the user’s password information for a website

Symptoms:

User starts IE8, types in “salesforce” in the address bar, which automatically brings him to to Salesforce.com. He clicks on the Login link, enters his Username and Password, checks off the box that says “Remember User Name”, and goes about his work. Afterwards, he closes out IE8 and then reopens it later on. He proceeds to Salesforce.com again, but it takes him to the login page and prompts for the password (User Name field is already populated). It should remember his password and log him in automatically.

Solution:

I added salesforce.com to the list of websites to be always allowed to use cookies (in the Per Site Privacy Actions in the Privacy tab of Internet Options). The change did not work. Next, I tried deleting all browsing history and made sure the “Preserve Favorites website data” was checked off (Press the Delete button under Internet Options –> General Tab –> Browsing history) and the “Delete browsing history on exit” option was NOT checked off . This too, did not work.

What did work was deleting all the salesforce.com bookmarks from the user’s Favorites!

Can Authorities Force You to Give Up Laptop Password?

cnet – Verizon Wireless: Yep, that’ll be $2 to pay your bill online

There’s news out that Verizon Wireless wants to charge me $2 every time I pay my bill online using the single pay option. That means, when I get my bill, I’ll be charged a “convienence fee” of $2 for going online and paying on their website. However’ if I pay by check, through the mail, or sign up of auto bill pay, I won’t get charged.

Whaaat???? What kind of nonsense is this?  So you’re saying that it would be cheaper for me to send in my money, as a check, through the mail?

This ranks right up there with Netflix’s price increases…and the nickle & diming airlines…But it makes little sense since they’re giving other options to pay.

Update (12/30/11):  Now according to CNN, Verizon is scraping the $2 due to “customer feedback”. What kind of feedback did they expect from customers?!?

Update (01/16/12):  Got my Verizon Wireless bill. It’s up $1.75 anyways due to “administrative charges”, Fed surcharges, and taxes. What a crock.

Read more on cnet — Verizon Wireless: Yep, that’ll be $2 to pay your bill online | Signal Strength – CNET News.

Spyware On Every Android (And Possibly Blackberry) Phone Out There

Per Gizmodo – Spyware on every Android (and possibly Blackberry and Nokia) phone out there…

If you have any decently modern Android phone, everything you do is being recorded by hidden software lurking inside…

Carrier IQ’s software is installed in your phone at the deepest level. You don’t know it’s there. You are never warned this is happening. You can’t opt-in and you certainly can’t opt-out.

The commercial spyware sits between the user and the applications in the phone so, no matter how secure and private your apps are, the spyware intercepts anything you do. From your location to your web browsing addresses and passwords to the content of your text messages.

This even happens using a private Wi-Fi connection instead of the carrier 3G or 4G connection.

Read more on Gizmodo –> Your Android Phone Is Secretly Recording Everything You Do.

Netflix Changing DVD Service Name To “Qwikster”?

Update: Netflix does a rewind! Abandons the Qwikster plan…

Got an email from, Netflix. They’re changing their DVD service name to “Qwikster”? Really? But the same lousy pricing?

Here’s the email:

Dear xxxx,

I messed up. I owe you an explanation.

It is clear from the feedback over the past two months that many members felt we lacked respect and humility in the way we announced the separation of DVD and streaming and the price changes. That was certainly not our intent, and I offer my sincere apology. Let me explain what we are doing.

For the past five years, my greatest fear at Netflix has been that we wouldn’t make the leap from success in DVDs to success in streaming. Most companies that are great at something – like AOL dialup or Borders bookstores – do not become great at new things people want (streaming for us). So we moved quickly into streaming, but I should have personally given you a full explanation of why we are splitting the services and thereby increasing prices. It wouldn’t have changed the price increase, but it would have been the right thing to do.

So here is what we are doing and why.

Many members love our DVD service, as I do, because nearly every movie ever made is published on DVD. DVD is a great option for those who want the huge and comprehensive selection of movies.

I also love our streaming service because it is integrated into my TV, and I can watch anytime I want. The benefits of our streaming service are really quite different from the benefits of DVD by mail. We need to focus on rapid improvement as streaming technology and the market evolves, without maintaining compatibility with our DVD by mail service.

So we realized that streaming and DVD by mail are really becoming two different businesses, with very different cost structures, that need to be marketed differently, and we need to let each grow and operate independently.

It’s hard to write this after over 10 years of mailing DVDs with pride, but we think it is necessary: In a few weeks, we will rename our DVD by mail service to “Qwikster”. We chose the name Qwikster because it refers to quick delivery. We will keep the name “Netflix” for streaming.

Qwikster will be the same website and DVD service that everyone is used to. It is just a new name, and DVD members will go to qwikster.com to access their DVD queues and choose movies. One improvement we will make at launch is to add a video games upgrade option, similar to our upgrade option for Blu-ray, for those who want to rent Wii, PS3 and Xbox 360 games. Members have been asking for video games for many years, but now that DVD by mail has its own team, we are finally getting it done. Other improvements will follow. A negative of the renaming and separation is that the Qwikster.com and Netflix.com websites will not be integrated.

There are no pricing changes (we’re done with that!). If you subscribe to both services you will have two entries on your credit card statement, one for Qwikster and one for Netflix. The total will be the same as your current charges. We will let you know in a few weeks when the Qwikster.com website is up and ready.

For me the Netflix red envelope has always been a source of joy. The new envelope is still that lovely red, but now it will have a Qwikster logo. I know that logo will grow on me over time, but still, it is hard. I imagine it will be similar for many of you.

I want to acknowledge and thank you for sticking with us, and to apologize again to those members, both current and former, who felt we treated them thoughtlessly.

Both the Qwikster and Netflix teams will work hard to regain your trust. We know it will not be overnight. Actions speak louder than words. But words help people to understand actions.

Respectfully yours,

-Reed Hastings, Co-Founder and CEO, Netflix

p.s. I have a slightly longer explanation along with a video posted on our blog, where you can also post comments.

500 Internal Server Error

Got a personal website hosted on Godaddy that all of a sudden started giving me 500 Internal Server Error:

I have the domain and hosting at Godaddy – Economy Linux hosting. I use WordPress as the front end. Not the WordPress setup they offer, but I uploaded my own WordPress files, setup a MySQL db, and configured everything manually. I use the site to host family pictures and videos. I haven’t made any changes in a month however all of a sudden I’m getting 500 Internal Server Errors.

During the course of my investigation, I found out it was due to my .htaccess file. The site worked without it, but why? It worked fine before!

Turns out it was the following line in the file:

# disable directory browsing
Options All -Indexes

I commented it out, and everything worked fine. Not sure if it’s a Godaddy issue or an Apache issue. Probably the former.

But I would think it would be prudent to disable directory browsing. However, what’s weird is that I have similar setups with Godaddy, including the Options All -Indexes, and have no issues…yet.

HuffPost – Texas Exposes Private Records: State Accidentally Releases 3.5 Million Personal Records

Epsilon e-mail Marketing Breach

By now, you may have heard of the security breach at mass email marketing company Epsilon, where the names and email addresses of thousands, if not millions, of people have been stolen. The current list of companies include:

  • 1-800-Flowers
  • AbeBooks
  • Ameriprise Financial
  • Barclays Bank
  • Best Buy
  • Brookstone
  • Citibank
  • Disney Destinations
  • Hilton Worldwide
  • JP Morgan Chase
  • Kroger
  • Lacoste
  • Marriott International
  • McKinsey Quarterly
  • New York & Company
  • Robert Half
  • Target
  • Tivo
  • US Bank
  • Verizon
  • Walgreens

The warning emails are starting to role in. This one from Target:

When will it become Standard Operating Procedure, and an industry standard, if you are storing customer info, to store it in an encrypted database! It can’t be that difficult!! The money you are spending on the resulting PR, could probably have been used to secure the database.

I blame, not only Epsilon, but also the companies that dealt with Epsilon for not making it a requirement that the customer info be encrypted.

Firefox 3.6.16 Back Button Not Working

McAfee Site Advisor Add-On broke my back button in Firefox!

Everything was fine and dandy until, my Firefox was updated to 3.6.16.  All of a sudden, the back button wasn’t working. Sooo, if I searched for something via Google, and clicked on a found link, I couldn’t go back to the search results page if I wanted to because the back button was grayed out!

As usual with these sort of updates, some other third-party extension broke this functionality.

I went through my Add-Ons list:

  1. AdBlock Plus
  2. AddThis
  3. Evernote
  4. Garmin Communicator
  5. Google Toolbar
  6. Java
  7. McAfee SiteAdvisor
  8. Microsoft .Net
  9. NoScript
  10. Nuke Anything
  11. ShortenURL
  12. WOT
  13. XMarks

I disabled all the add-ons and one-by-one re-enabled them, restarting my Firefox each time. to see which add-on broke the back-button.

Turns out, it was McAfee SiteAdvisor. I compared it with another user who posted a list of add-ons he had, and who also lost the back button function. He too had McAfee SiteAdvisor.

Sooo, if your back button stops working, and you have McAfee SiteAdvisor, disable it and try it out.  If you don’t have that add-on, try the method of disabling all your add-ons and re-enabling them, one-by-one, to isolate the culprit:

  1. From the menu bar go to Tools–> Add-ons [to open the Add-ons window]
  2. Select Extensions on top
  3. Click on the Add-on
  4. Click “Disable” then “Close”
  5. Restart Firefox