• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue Schedule delete files

tanasis

Basic Pleskian
Hello,
i want every Monday to delete a directory.

I'm using the command
rm -R -f /var/www/vhosts/example.com/public_html/image/cache
as "Task type: Run a command" but doesn't delete file.

Can you help me?
 

Attachments

  • image2006.jpg
    image2006.jpg
    17.9 KB · Views: 10
Try to define the full path to the command /usr/bin/rm
 
Check the logfile /var/log/cron to find out what the issue is.

Run:
# tail -f /var/log/cron

and excute the cron command in the GUI.
 
Check the logfile /var/log/cron to find out what the issue is.

Run:
# tail -f /var/log/cron

and excute the cron command in the GUI.


When i run the Schedule Task (i press the button Run Now), i get a successful message : Task "/usr/bin/rm -R -f /var/www/vhosts/example.com/public_html/image/cache" successfully completed in 0 seconds.

Also, i don't have errors. But the files, doesn't delete
 

Attachments

  • image2020.jpg
    image2020.jpg
    46.2 KB · Views: 8
Ok, I tested this on a local Plesk server.

If you run this command as a non-root user, the user doesn't know about /var/www/vhosts/subscription

So, the command becomes something like this:
Code:
/bin/rm -rf /public_html/image/cache/*

The log file is /var/log/plesk/task-manager.log, not /var/log/cron.

By the way: what's the deal with the public_html folder? Plesk uses httpdocs as the root directory for the subscriptions.
 
Doesn't delete files, not errors....

INFO 2022/08/19 14:08:32 task=107755 process=107755 trace=4100641:62ff6f3082e5b Starting as 'run-plesk-task-107755.service' systemd unit with command: [/usr/local/psa/admin/bin/php /usr/local/psa/admin/plib/scripts/task-async-executor.php -task-id 4316]
INFO 2022/08/19 14:08:32 task=107755 process=107755 Finished with exit code 0 and 'success' status in 878.366499ms, unit finished in 306.29ms

By the way: what's the deal with the public_html folder? Plesk uses httpdocs as the root directory for the subscriptions.
Because the was a migration from cPanel.
 
Save your rm command (with full path for rm) in /var/spool/cron/root
Then run : crontab /var/spool/cron/root
 
I still can't get this working via the Schedule a Task in Plesk.. Is it not possible?

Tried

/bin/rm -rf /public_html/temporary/*

rm -f /public_html/temporary/*
Any other suggestions? As the other poster mentioned there is no log output except success, but files are not deleting.

And I also migrated from Control panel and can confirm that files remain in /public_html/
 
I suppose your /public_html/temporary/* path is wrong.
Shouldn't it be /var/www/vhosts/DOMAIIN.COM/public_html/temporary/* or something like that ?
 
I still can't get this working via the Schedule a Task in Plesk.. Is it not possible?

Tried

/bin/rm -rf /public_html/temporary/*

rm -f /public_html/temporary/*
Any other suggestions? As the other poster mentioned there is no log output except success, but files are not deleting.

And I also migrated from Control panel and can confirm that files remain in /public_html/

The problem still exists... If you find any solution please let me know.
 
@tanasis The path is wrong. You are starting the path with a / which means that public_html branches off the directory root of the server. No Linux distribution does that. What you probably want is to remove a public_html directory that branches off your subscription root directory. That would be /var/www/vhosts/DOMAIN.COM. AS @Kniar had already pointed out, the parameter must then be /var/www/vhosts/DOMAIN.COM/public_html/temporary/* else the command must fail as it cannot find the public_html.
 
Can confirm that -

/bin/rm -rf /var/www/vhosts/DOMAIN.com/public_html/temporary/*

and

/bin/rm -rf /var/www/vhosts/DOMAIN.com/public_html/temporary/*.jpg

Deletes all files or only *.jpg ...

Thank you.|
 
You're correct but notice that :

/bin/rm -rf /var/www/vhosts/DOMAIN.com/public_html/temporary/*

deletes all files and directories
 
No, doesn't work...

The command:
/bin/rm -rf /var/www/vhosts/DOMAIN.COM/public_html/image/cache/*


1668726667417.png

...and im getting
image2402.jpg


If i run the command via ssh terminal, everything is working fine....


(please remove Resolved from subject)
 
Could you please describe why from your point of view "successfully completed" ist not a successful completion of the task?
 
Back
Top