Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: temp file issue

  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    temp file issue

    Hi,

    My MySQL query creates a file in the dir /tmp. I want to delete this file as soon as it is no longer required. I want to ensure that any other MySQL users temp file isn't deleted before their query has finished with it.

    How can I determine which temp file is the one I want to remove? My current thought is simply to delete all files that were created more than 24 hrs ago.

    what would you suggest?

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,942
    Thanks
    2
    Thanked 169 Times in 164 Posts
    Are you creating the files yourself, or are they being created by mysql?

    I have not used mysql temp files, but it's my understanding that if mysql created the file as part of a query, then it will delete the file when it's done with it.

  • #3
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    they are being created by mysql.

    I am running a query as below and it works OK.

    It seems that mysql is making the temp file and, as I found out this morning, they don't seem to be being deleted when they are no longer required (as I thought they should be).

    Maybe I need to make a mysql setup change (from its default)?

    BTW, the only reason I think it is a temp file issue is that the error was coming from the 'execute' line. Other than that, I would have thought it was the session file that was doing it. Now, as a secondary issue, sessions are terminated when the browser is closed. But they too are not yet being deleted from the server. What is the simplest way to prevent session files from filling up the temp dir? cron job or a small function in each script of my master login? (Never done a cron before).


    Code:
    my $sth = $connect->prepare ("select 
      fd.file_name_other_language
    , fd.file_heading
    , fd.file_text
    , fd.text_block_sequence 
    , fd.text_or_list 
    , fd.is_it_highlighted 
    , fs.sequence_number
    , fi.image
    from file_data AS fd
    left outer
    join file_sequencing AS fs
    on fs.file_id = fd.file_id
    left outer
    join file_images AS fi
    on fi.id = fd.id
    where fs.business_id = ?
    and fd.file_name_other_language = ?
    and fd.language_abbr_this_file = ?
    and fs.live_from = ( select max(b.live_from)
                            from file_sequencing as b
                             where b.business_id = fs.business_id
                               and b.live_from <= curdate()
                               and b.file_name_in_home_language = fs.file_name_in_home_language
                               and ( ( fs.live_to = '0000-00-00')
    			           or
    				   (fs.live_to > curdate() )
    				)  
                        )
    order by fd.text_block_sequence asc 
                         ") or die "prepare statement failed: $DBI::errstr\n";
    
      $sth->execute( $business_id, $subject, $chosen_language ) or die "execute statement failed: $DBI::errstr\n";
    bazz
    Last edited by bazz; 01-05-2011 at 05:03 PM.
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •