This question already has an answer here:
I'm making a 1.12 map that need to do something when a player join. I tried
stats.leavegame method, but if the game crashed the last time, the command won't run.
No file permission for it's hard to share, but unintended file type (like using a file to take the place of a folder, in my answer) is fine