Cleaning custom tmp files in VestaCP

Linux Server Management Tips and Tricks
Post Reply
arnlweb
Site Admin
Posts: 95
Joined: Wed Jun 22, 2016 1:28 pm
Location: India
Contact:

Cleaning custom tmp files in VestaCP

Post by arnlweb » Wed Dec 07, 2016 9:40 am

Sometimes turned out large number of vestacp sess_ * files in the directory "/home/admin/tmp"

Create a script to delete files daily.

Create the file: /usr/local/vesta/bin/vestacp_sess.sh with content

Code: Select all

/usr/bin/find /home/*/tmp -name "sess_*" -type f -cmin +24 -print0 | /usr/bin/xargs -r -0 rm >/dev/null 2>&1
or

Code: Select all

find /home/*/tmp -type f -name 'sess_*' -ctime +5 -delete
Let's make it executable

Code: Select all

chmod a+x /usr/local/vesta/bin/vestacp_sess.sh
Then create a cron job from vesta admin.

Another method:

Standard kronovskumu scavenger debian following line:

file location: "/etc/cron.d/php5"

Add this line:

Code: Select all

09,39 * * * * root /usr/bin/find /home/*/tmp -name "sess_*" -type f -cmin +24 -print0 | /usr/bin/xargs -r -0 rm >/dev/null 2>&1


Hope it helps.

arnlweb
Site Admin
Posts: 95
Joined: Wed Jun 22, 2016 1:28 pm
Location: India
Contact:

Re: Cleaning custom tmp files in VestaCP

Post by arnlweb » Sat Jul 22, 2017 9:12 am

File Location: /etc/cron.d/php


# /etc/cron.d/[email protected][email protected]: crontab fragment for PHP
# This purges session files in session.save_path older than X,
# where X is defined in seconds as the largest value of
# session.gc_maxlifetime from all your SAPI php.ini files
# or 24 minutes if not defined. The script triggers only
# when session.save_handler=files.
#
# WARNING: The scripts tries hard to honour all relevant
# session PHP options, but if you do something unusual
# you have to disable this script and take care of your
# sessions yourself.

# Look for and purge old sessions every 30 minutes
09,39 * * * * root [ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean
09,39 * * * * root /usr/bin/find /home/*/tmp -name "sess_*" -type f -cmin +24 -print0 | /usr/bin/xargs -r -0 rm >/dev/null 2>&1

Post Reply