deleting old session files in /tmp

Conclave

New member
Joined
May 9, 2005
Messages
2
Ok, here is the rundown of the issue:

We are creating a game&forum site. We are the stage of checking for session files older than 900 seconds (15 minutes).

At this point, our script checks the /tmp dir for $file_name with a substring of sess_ (designating a session file). Then, we check the file for what we call a group session varible (all the site sessions will have this variable to tell it apart from other users sessions in the /tmp directory)

if we get a match on the group session variable we then find the username, compare it to the databases lastactivity field. If the span is >900 sec, we delete the session file.

In Testing, this worked great, as long as we ran it from a browser. But as soon as we put it into a Cron, we got permission denied errors for the actual reading of the file.

Now, my questions are:

1. Why is it i can read a session file as a visiter, and not as the domain admin in a cron job?

2. on that note, how do i go about this without having to create a custom ini file for this server and changing the path.

I know for efficiency, we should do it with custom ini and session folder, but, we dont want to mess with all that stuff until we figure it out at the root level.

er...ok well i tried it anyways (setting sessionpath at runtime) and i still got the same cronjob error, the chomod on the custom sessionpage files was 600, 777 on the folder. and DA wont let me change permission on a sess_ file.

Anyways, can anyone shed some lite on this?
 
Last edited:
Your script will probably need to be run as root so it has sufficient permissions to run it's operations. Add your cronjob to the master cronjob file with a preceding root.

e.g. * * * * * root comand
 
Dont have root access. Already discussed this with the server owner and we agreed the less run as root user the better. Any other suggestions? To work around this issue?
 
Back
Top