Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

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

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Employee

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

View solution in original post

10 Replies

Avatar

Level 10

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

Correct answer by
Employee

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

Avatar

Level 2

Thanks   Amit for cofirmation.

We had completed that process and its working now.

Avatar

Level 10

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

Employee

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

Level 5

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

Employee

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

Level 1

thanks Adhiyan,
We have a scenario to cleanup of old files of one month, could you give code snippet to achieve this.

~Thanks

Avatar

Level 5

Hi Adhiyan,

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

Regards,

Adithya