• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

Schedule an exchange shell task to clear log files

I have a exchange shell script that I run manually to clear out a bunch of log files that are created by exchange which eats up storage space on our environment.

Unfortunately, I cannot get this to work as a scheduled task as it keeps failing. Can anyone guide me to help automate this?
0
MSSC_support
Asked:
MSSC_support
1 Solution
 
Colin McDonaldCommented:
Can you provide details of the error received when running the scheduled task?

Can you provide screen shots of task settings
0
 
MSSC_supportAuthor Commented:
Ok.  At the moment I have it configured to run whether user is logged on or not and with highest privileges.

The program/script is set to:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

and argument:

-NonInteractive -WindowStyle Hidden -command ". 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; 'C:\Purge Logs\Purge-LogFiles keep 7 days.ps1'"

The error message i get is 0x0.

Hope this helps.
0
 
David Johnson, CD, MVPOwnerCommented:
a return of 0 normally means success, non zero means failure. Have you tried circular logging or getting an exchange aware backup
0
 
VB ITSSpecialist ConsultantCommented:
I use this line in a batch file to do the same thing, but for IIS logs. You can try this as opposed to using a PS script, works perfectly fine as a Scheduled Task:
forfiles /p "C:\logs" /m *.log /d -7 /C "cmd /c del @file"

Open in new window

Feel free to replace del @file  with echo @file to get a list of which files the script will delete. This is what I do when I want to test the batch file.
0
 
MSSC_supportAuthor Commented:
This works but is slightly more risky.
0

Featured Post

Easily manage email signatures in Office 365

Managing email signatures in Office 365 can be a challenging task if you don't have the right tool. CodeTwo Email Signatures for Office 365 will help you implement a unified email signature look, no matter what email client is used by users. Test it for free!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now