Delete Server Files at /usr/local/neolane/nl6/var/..

Avatar

Avatar

sourabhk3112

Avatar

sourabhk3112

sourabhk3112

20-02-2018

Hi Team,

We want to delete those Files which we will upload at Local Server In data Loading activity.

Is there any way to delete those files.

Now we are getting below error to overcome this error we want to delete data from server. Or If anything else required please suggest.

02/20/2018 7:16:13 AM CRL-290002 Download error in cURL

02/20/2018 7:16:13 AM CRL-290002 Download error in cURL

02/20/2018 7:16:13 AM BAS-010015 Cannot open file'/usr/local/neolane/nl6/var/Client/workflow/DELL_Loyalty_US_Member_Balance_20180218_20180220131613a.txt' with write access (errno=28, No space left on device)

Thanks

Sourabh

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Adhiyan

Employee

Avatar

Adhiyan

Employee

Adhiyan
Employee

26-02-2018

Hello Sourabh,

You can delete files from a directory in the app server using JS functions.

You need to make use of the file.remove() function if the Jsapi.chm documentation.

Please follow the steps mentioned below:

Create a new workflow and name it as per convention.

Drag and drop the 3 workflow activities(start , JS and End) on to the canvas and then connect them.

Double click on JavaScript code activity and rename it to your liking.

Insert the following code inside JavaScript activity to fetch our goal.

// Define server folder path where to search for

var strFolderPath = "/usr/local/neolane/nl6/var/Client/workflow/"

// In the above path "client" is your instance name

// Define file match pattern

var strPattern = "*.txt"

// We are looking for all files that have an extension as csv

// Open a directory object to fetch its data

var objDirectory = new File(strFolderPath)

// Get access to all files inside the directory that match the search pattern

var objFiles = objDirectory.list(strPattern)

// Log the count of files

logInfo("No. of files that match search criteria are : " + objFiles.length)  -- This step is optional and needed just if you need to verify the number of files

// remove all the files in the directory /usr/local/neolane/nl6/var/Client/workflow/

for each(var objFile in objFiles)

{

        objFile.remove();

}

**************************************************************************************************************

Please take a look all other patterns that can help you search.

"*.*" : all files.

"*.txt" : all text files.

"A*.*" : all files whose name start with A

"A*z.*" : all files whose name start with A and ends with Z.

Regards,
Adhiyan

Answers (8)

Answers (8)

Avatar

Avatar

Adhiyan

Employee

Avatar

Adhiyan

Employee

Adhiyan
Employee

27-02-2018

Hi Amit,

Agree. That is why there is an option to search for the files needed.

you can modify the variable var strPattern as per the need and can mention the filename if needed.

Regards,

Adhiyan

Avatar

Avatar

Amit_Kumar

MVP

Avatar

Amit_Kumar

MVP

Amit_Kumar
MVP

27-02-2018

Hi Adhiyan ,

Thanks for providing the script but This is not a right way as this might delete the files which are required in other workflows so it's very important that you file your files for delete so that you only delete files which are not required by any other workflow. This way users may end up corrupting other important workflows.

Regards,

Amit

Avatar

Avatar

Amit_Kumar

MVP

Avatar

Amit_Kumar

MVP

Amit_Kumar
MVP

26-02-2018

Hi Sourabh,

Are you using an on-premise environment? Or this is Adobe hosted environment?

If this is On-premise, then ask your admin to provide RDX access 'neolane' user for var folder. Write a workflow and use script activity to execute a shell script to delete all files. You can schedule this workflow to clean the space based on the last modification date of files. otherwise, raise a daycare ticket to do the same for you neolane support will be able to do this for you.

Regards,

Amit

Avatar

Avatar

adithyacs86

Avatar

adithyacs86

adithyacs86

20-11-2018

Hi Adhiyan,

Thanks for the code I will try and let you know for any further queries.

Regards,

Adithya

Avatar

Avatar

Adhiyan

Employee

Avatar

Adhiyan

Employee

Adhiyan
Employee

19-11-2018

Hello Adithya,

The script is correct if you are just trying to see the no. of files in that location. If you want to know the names of the file along with last modified date, please add the following lines to the code :

// Scroll through every file and log its details

for each(var objFile in objFiles)

{

          logInfo(objFile.name + ": last modified at " + objFile.lastModified)

}

Also , the file.remove() function will remove all the files which are returned from the search result.

1625209_pastedImage_0.png

Regards,
Adhiyan

Avatar

Avatar

adithyacs86

Avatar

adithyacs86

adithyacs86

19-11-2018

Hi Adhiyan,

 

I came across similar issue, we are asked to clean up the var folder which is Adobe Hosted. Can you please let me know if the process which i followed per above is correct, Just to note I am just trying to see the data / files in the upload folder.

 

var strFolderPath = "<path>"

 

var strPattern = "*.csv"

 

// We are looking for all files that have an extension as csv

 

 

// Open a directory object to fetch its data

 

var objDirectory = new File(strFolderPath)

 

 

// Get access to all files inside the directory that match the search pattern

 

var objFiles = objDirectory.list(strPattern)

 

 

 

// Log the count of files

 

logInfo("No. of files that match search criteria are : " + objFiles.length)

 

 

and I am not sure of the file.remove() function if the Jsapi.chm documentation, can you please explain a bit more on this.

 

Thanks,

Adithya

Avatar

Avatar

sourabhk3112

Avatar

sourabhk3112

sourabhk3112

26-02-2018

Thanks Adhiyan​ .

Avatar

Avatar

sourabhk3112

Avatar

sourabhk3112

sourabhk3112

26-02-2018

Thanks   Amit for cofirmation.

We had completed that process and its working now.