Link to home
Start Free TrialLog in
Avatar of Lev Seltzer
Lev SeltzerFlag for Israel

asked on

Delete a folder on a linux computer on a regular basis

There is a CRON job somewhere in the world that creates a "/boutique" folder within my client's public_html folder. The existance of this folder causes the client's boutique to stop working, since apache shows the empty folder rather than using WordPress's redirects to show the appropriate page.

We do NOT know where the CRON job comes from and we may never find it. So we are looking for a different solution.

Within cpanel and WHM there is the ability to run CRON jobs. Perhaps I could create a CRON job that would erase the "/boutique" folder, and I could configure this to run every hour or so.

The problem is that I don't know how to do this. Could someone help me?

Thank you.
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

not really a "solution", as you still risk to run the cron in a way that it tries to delete the folder just before it is created, and the site is down most of the time.
the folder may be created by one of the pages itself, so do a search on the code files themselves to start with.
is this some from-the-shelf solution for the "boutique"? it may also be that solution trying to do this...

if there you find nothing, check with the hosting provider, but this is very unlikely
SOLUTION
Avatar of Member_2_406981
Member_2_406981

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
create a no-permission file called boutique and script that messes with it will send you warning mail.
Avatar of Lev Seltzer

ASKER

Guy Hengel: We are using WooCommerce today, but in the past we had a drupal shopping cart located in the /boutique folder. I suspect that there might be code remaining, but i have seemingly deleted it all, and can't find what is the cause of this folder creation. At this point I am not looking for a solution to stop the creation. I only want to delete the folder, and I am happy to have a cron job run every minute (if necessary) to make sure the folder is not there.


andreas: I created a test folder /DeleteTest and a cron job:
* * * * * * rm /DeleteTest

I get the error (via email)
rm: cannot remove `/DeleteTest': No such file or directory

I tried the same with /public_html/DeleteTest and received the same error.
(I made sure to write the folder name properly, with upper and lower case as required).
What could be wrong?

gheist: I do not know what a "no-permission" file is or how to create it with cpanel. However, I would suspect that if I have ANY file or folder name "boutique" then WordPress will attempt to display that file/folder rather than redirect to the WooCommerce storefront. It certainly happens now when a FOLDER is created.
Avatar of Member_2_406981
Member_2_406981

is the test folder gone?

if yes the mail is from the next run of the job

as its running every minute as you did it now.
No, it is not gone. I received a dozen of the messages over 12 minutes, and each one said that it failed. I changed the CRON job slightly (as per my previous response) and it still failed. The cron job reported that it failed in the email, and the test folder was - and is - still there.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
WE are getting VERY CLOSE!

Cron job ran. it found the directory. But it could not delete it:

rm: cannot remove `./public_html/DeleteTest': Is a directory

Perhaps "rm" is not the right command to remove a folder?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This worked and deleted the test folder. Hopefully this will work with the real issue when it next happens.

Thank you very much for all your help.