Lev Seltzer
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.
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
create a no-permission file called boutique and script that messes with it will send you warning mail.
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.
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.
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.
if yes the mail is from the next run of the job
as its running every minute as you did it now.
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
Cron job ran. it found the directory. But it could not delete it:
rm: cannot remove `./public_html/DeleteTest'
Perhaps "rm" is not the right command to remove a folder?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
Thank you very much for all your help.
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