Welcome Guest, Not a member yet? Register   Sign In
running code on logout
#1
Wink 
(This post was last modified: 03-03-2021, 07:20 AM by richb201.)

I have a C3 application that will be hosted as a webapp. I need to clean up files that accumulate in the /assets/uploads/ directory. I do have a logout button and I can go through the mysql table that holds the filenames and clean up when a user logsout. But how about when a user just presses the 'X' in the tab? Is there anyway I can force a function to run at that time? 

From my limited understanding of how CI works in a multiuser app, all users are sharing that same /assets/uploads/ directory. So I can't just obliterate that directory. Right? 

I have actually come up with a simpler solution. Seems that AWS CLI supports:
aws s3 sync s3://example-bucket .
aws s3 sync . s3://example-bucket

Which will synch a certain dir up to and back from S3 to the server. To run this I will need to cd to the directory I want to synch, and then will want to run this is in a non-blocking shell. In the article Wainstein talks about using cron but I am concerned about that delaying updating the servers.

Is it possible to run a cron job on demand (for example, when a new user logs in?).
proof that an old dog can learn new tricks
Reply
#2

@richb201,

Your definitely heading in the right direction. You could create a method or function or stand alone program that is automatically executed when a user logs off or presses the x in the tab.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB