on 08-02-2017 2:20 PM
Hello Guys,
I want to remove the xml files based on the retention period from "path/folder" in the sap bods using unix script.
ex:if i give $GV_RETENTION_PERIOD = 4 means,it should delete the xml files from the path sharepath/folder other than 4 days.
print( exec('ksh', '-c "find sharepath/folder -type f -name \'*.xml\' -mtime +[$GV_RETENTION_PERIOD] -exec rm {} " ' , 8));
But the script is not working,its throwing the error like this:
error---> 1: find: invalid argument `1' to `-mtime'.
i tried another way also,but not working
print( exec('ksh', '-c "findsharepath/folder -type f -name \'*.xml\' -mtime + [$GV_RETENTION_PERIOD] -delete" ',8));
but throwing the same error:
error---> 1: find: invalid argument `1' to `-mtime'.
Please help on this,wehre iam doing wrong.
Thanks
SKB
For deleting files in the Archive folder you can use below code.
Replace the GV with your path and change the values +30, below code is used to removing the files which is older than 30days.
For Linux environment :
print( exec('ksh', '-c "find [$G_FILE_DELETE] -mtime +30 -delete " ' , 8));
For Windows:print(exec( 'powershell','"Get-ChildItem –Path
[$G_FILE_DELETE] –Recurse | Where-Object\{$_.LastWriteTime –lt (Get-Date).AddDays(-30)\} | Remove-Item"',8));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Experts,
Can some one give the syntax in unix .
Thanks
SKB
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arun,
Thanks for prompt reply.
Can you please provide the syntax by using the CMS in windows.
i will try to execute it.
Thanks
SKB
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It works when using the CMD in windows but not sure about passing the global variable in unix shell command.
2211245 - How to pass a Global Vairable in Exec() - Data Services
Can you check with SAP Support Team.
Regards
Arun Sasi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.