Background / Problem: I have 2 machines sharing a file directory using Google drive. I edit the shared files using Emacs on both machines alternatively everyday. I would like to make sure that at most one active Emacs session is running at a time to avoid sync conflict due to multiple active sessions with unsaved files.
Idea: I would like to make Emacs to save the time-stamp and hostname to some shared log file whenever I close it, so that I can check the log entry when I open Emacs on another machine next time. That makes sure my previous Emacs sessions was closed and all files were saved and synced/up-to-date.
Implementation: I would like to add a function to kill-emacs-hook to append or replace time-stamp and hostname in a log file. The log file can be a org-mode file with a heading "Last session close time", so that I can replace the old content (i.e., old time-stamp and hostname) under that heading in the function. How can I do that?
Or: Is there any package provide the "last session time" logging for us?
Another question (please let me know if I should create a new question on stackexchange): We can open an org-mode file automatically when starting Emacs. Can we make sure a specific heading (in my case "Last session close time") is shown on startup?