#1  
Old 16th April 2010, 14:10
robertlouwen robertlouwen is offline
Senior Member
 
Join Date: Apr 2009
Location: Brielle, Netherlands
Posts: 141
Thanks: 20
Thanked 3 Times in 2 Posts
Default cronjob for php-session

Hello all,

I want session files older than 30 minutes automatic deleted and according to this information found in php.in I have to create cronjob or a script
Code:
; NOTE: If you are using the subdirectory option for storing session files
;       (see session.save_path above), then garbage collection does *not*
;       happen automatically.  You will need to do your own garbage
;       collection through a shell script, cron entry, or some other method.
;       For example, the following script would is the equivalent of
;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
;          cd /path/to/sessions; find -cmin +24 | xargs rm
My path to session is /var/lib/php/session so I tried the following possibilities:
[root@obelix ~]# crontab -e
Code:
*/30 * * * * root find -cmin +30 | xargs rm /var/lib/php/session &> /dev/null
Code:
*/30 * * * * root /var/lib/php/session find -cmin +30 | xargs rm /var/lib/php/session  &> /dev/null
Code:
*/30 * * * * cd /var/lib/php/session find -cmin +30 | xargs rm &> /dev/null
None of them work.

Who knows the right syntax ?
__________________
With Respect, Robert
------------------------------------------------
Fedora 15 - ISPConfig v3.0.3.3
On Dell Optiplex GX270, Pentium 4, 2.8 GHz, 1024 Mb
Reply With Quote
Sponsored Links
  #2  
Old 17th April 2010, 18:15
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,741 Times in 2,575 Posts
Default

Take a look at http://www.howtoforge.com/back_up_my..._interruptions

The /usr/local/sbin/mysqlbackup.sh script should give you the idea how to do this.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
The Following User Says Thank You to falko For This Useful Post:
robertlouwen (17th April 2010)
  #3  
Old 17th April 2010, 18:56
BorderAmigos BorderAmigos is offline
Senior Member
 
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 33 Times in 31 Posts
Send a message via MSN to BorderAmigos Send a message via Yahoo to BorderAmigos
Default

My php set up has this cron job to delete sessions every 30 minutes. In /etc/cron.d/php5 file...

Code:
0,30 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -print0 | xargs -n 200 -r -0 rm
You may want to change php5 to php in your setup.
__________________
System6Hosting.com, ISPConfig 3, Debian.
Reply With Quote
  #4  
Old 17th April 2010, 22:02
robertlouwen robertlouwen is offline
Senior Member
 
Join Date: Apr 2009
Location: Brielle, Netherlands
Posts: 141
Thanks: 20
Thanked 3 Times in 2 Posts
 
Default

@ Falko,

At first I thought "stop this is too difficult for me" my second thought was "a challenge"

What you say is make a script and make a cronjob for the script.
From your example I only need
Code:
#!/bin/sh

datum=`/bin/date +%Y%m%d-%H`

for file in "$( /usr/bin/find /home/sqlbackup -type f -mtime +2 )"
do
  /bin/rm -f $file
done

exit 0
and adjust this

Code:
"$( /usr/bin/find /home/sqlbackup -type f -mtime +2 )"
do
  /bin/rm -f $file
to

Code:
"$( /usr/bin/find  /var/lib/php/session -type f -cmin +30 )"
do
  /bin/rm -f $file
Code:
chmod 755 /usr/local/sbin/cleanup.sh
Finaly I create the cronjob
Code:
*/30 * * * * /usr/local/sbin/cleanup.sh &> /dev/null
I will give this a try.

@BorderAmigos,

I am challenged by Falko's suggestion, if I fail I use your cronjob.
__________________
With Respect, Robert
------------------------------------------------
Fedora 15 - ISPConfig v3.0.3.3
On Dell Optiplex GX270, Pentium 4, 2.8 GHz, 1024 Mb
Reply With Quote
Reply

Bookmarks

Tags
cron, ispconfig 3.0.2.1, php, session

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hacking attack (ubuntu 7.04 server + local root exploit on kernel) smoko General 4 15th September 2013 05:05
Statistic not working mzo Installation/Configuration 49 20th April 2011 12:19
Question about Virtual Hosting With Proftpd And MySQL (Incl. Quota) On Debian Etch ikkem HOWTO-Related Questions 30 26th February 2008 19:38
FTP Error joshabts Installation/Configuration 3 4th November 2006 16:19
Website users? ctroyp General 25 6th January 2006 18:02


All times are GMT +2. The time now is 19:56.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.