Skip to content

Instantly share code, notes, and snippets.

@epsa-dev
Last active February 17, 2023 17:46
Show Gist options
  • Save epsa-dev/1db46fd3ef850fe9b4d5f318dca8f232 to your computer and use it in GitHub Desktop.
Save epsa-dev/1db46fd3ef850fe9b4d5f318dca8f232 to your computer and use it in GitHub Desktop.
Terminal: Buscar, mover, listar, eliminar

Checar el tamaño de carpetas:

du -h --max-depth=1 

Elimina error_log:

find -name "error_log" -exec rm -f '{}' \;

Mueve archivos a otra carpeta:

find -name "error_log" -exec mv '{}' /home/epsa/basura_el/ \;

http://www.ducea.com/2008/02/12/linux-tips-find-all-files-of-a-particular-size/

Buscar archivos:

find -type f -exec ls -lh {} \;
find -name "error_log" -type f -exec ls -lh {} \;
find -name "error_log" -type f -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
find -name "error_log" -type f -exec ls -lh {} \; | awk '{ print $5 ": " $9 }'

**Por tamaño: **

find /home/ -type f -size +512k -exec ls -lh {} \;

Espacio en virtfs: https://www.digitalocean.com/community/questions/virtfs-consuming-a-lot-of-space-cpanel http://docs.cpanel.net/twiki/bin/view/AllDocumentation/WHMDocs/VirtFS

Make sure that no users have jailed shell access in the "Manage Shell Access" interface. You can then use the script that you found in the blog post to unmout any bind-mounted directories:

for i in `cat /proc/mounts | awk '/virtfs/ {print $2}'`; do umount $i;done

CPanel also provides a script to remove the virtfs mounts:

/scripts/clear_orphaned_virtfs_mounts --clearall

How to Delete Every error_log File on a cPanel Server: https://www.webcitz.com/blog/tutorials/how-to-delete-every-error_log-file-on-a-cpanel-server.html

Locate All error_log Files:

find /home/*/public_html -type f -name error_log -exec du -sh {} \;

Locate All error_log Files and Sort by Disk Size:

find /home/*/public_html -type f -name error_log -exec du -sh {} \; | sort -n

Locate All error_log Files Over 100MB:

find /home/*/public_html -type f -name error_log -size +100000k -exec du -sh {} \;

Delete All error_log Files:

find /home/*/public_html -type f -iname error_log -delete

Delete All error_log Files Over 100MB:

find /home/*/public_html -type f -iname error_log -size +100000k -delete

Cron-Based Deletion of cPanel Server Error Log Files To setup a cronjob to run one of the two deletion commands above on a scheduled basis, you can do the following:

crontab -e

Which will open the crontab for root, then insert at the bottom of the file this command to delete all error_log files every day at 11PM server time:

* 23 * * * find /home/*/public_html -type f -iname error_log -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment