Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

yadav_anil782
Contributor II

log files deletion in Qlik sense

Hello Qlik Expert,


i am using below script for deleting qlik sense log file more then 7 days but it is not working fine.


could you please suggest anyone that what i need to do changes in script


MOVE "C:\ProgramData\Qlik\Sense\Log\Script\"*.* "E:\ANIL PERSONAL\Log Archive\"


MOVE "C:\ProgramData\Qlik\Sense\Repository\Archived Logs\anil4872\Script\*.*" "E:\ANIL PERSONAL\Log Archive\"


Forfiles /P "E:\ANIL PERSONAL\Log Archive" /M *.log /D -7 /C "cmd /c del @file /q"


rsvebeck

@ Kevin Case

Qlik Sense Forums

1 Solution

Accepted Solutions
yadav_anil782
Contributor II

Re: log files deletion in Qlik sense

Hello All,

i got my solution from below Script and it is working fine.

forfiles /p "E:\QlikSenseSharedData\Archived Logs" /s /m *.log* /D -180 /C "cmd /c del


@path"




Syntax

      FORFILES [/p Path] [/m SrchMask] [/c Command] [/d [+ | -] {date | dd}]  


Key

   /p Path      The Path to search  (default=current folder)


   /m SrchMask  Select files matching the specified search mask

                default = *.*


   /s           Recurse into sub-folders


   /C command   The command to execute for each file.

                Wrap the command string in double quotes.

                Default = "cmd /c echo @file"


                The Command variables listed below can also be used in the

                command string.


   /D date      Select files with a last modified date greater than or

                equal to (+), or less than or equal to (-),

                the specified date, using the region specific date format

                typically "MM/DD/yyyy" or "DD/MM/yyyy"

View solution in original post

5 Replies
RSvebeck
Valued Contributor

Re: log files deletion  in Qlik sense

Hi!

I have this sub and it works for me:

Sub DeleteOldFiles (vPath,vNoOfDaysToKeep)

  LET command = 'forfiles /P $(vPath) /S /M *.* /D -$(vDaysToKeep) /C "cmd /c del @PATH"';

  execute cmd.exe /c $(command) ;

End Sub;

Svebeck Consulting AB
kevincase
Contributor II

Re: log files deletion in Qlik sense

Anil,

Are both MOVE statements working correctly?

Is it just the FORFILES command that is failing?

The assumption is that you are still in synchronized persistence and that you have files in "E:\ANIL PERSONAL\Log Archive" that are more than 7 days old.

yadav_anil782
Contributor II

Re: log files deletion  in Qlik sense

Hello Kevin,

Move command is also not working.

still i am facing  issue to delete the older then 7 days logs

RSvebeck
Valued Contributor

Re: log files deletion in Qlik sense

Hi


1/ Make sure the qlikview service acount is running with sufficient access rights. This can sometimes be done by loging in to the server with that acount and see if you with File Explorer can delete/move files from that directory manually.


2/ Check that your batch script works in the command.exe while logged in to the same account as Qlikview services uses. Basically type the whole command in the cmd.exe ”dos” window (the black screen)


3/ if above works, did you permit ”allow execute” in the Sense or Qlikview server?


regards

 Robert

Svebeck Consulting AB
yadav_anil782
Contributor II

Re: log files deletion in Qlik sense

Hello All,

i got my solution from below Script and it is working fine.

forfiles /p "E:\QlikSenseSharedData\Archived Logs" /s /m *.log* /D -180 /C "cmd /c del


@path"




Syntax

      FORFILES [/p Path] [/m SrchMask] [/c Command] [/d [+ | -] {date | dd}]  


Key

   /p Path      The Path to search  (default=current folder)


   /m SrchMask  Select files matching the specified search mask

                default = *.*


   /s           Recurse into sub-folders


   /C command   The command to execute for each file.

                Wrap the command string in double quotes.

                Default = "cmd /c echo @file"


                The Command variables listed below can also be used in the

                command string.


   /D date      Select files with a last modified date greater than or

                equal to (+), or less than or equal to (-),

                the specified date, using the region specific date format

                typically "MM/DD/yyyy" or "DD/MM/yyyy"

View solution in original post