A process launched from cron
will have cron
as its parent process.
Of course, in the general case, a process launched from a process which was launched from cron
will have cron
as its grandparent; and if the launcher process was a child of cron
but is now terminated, the child process will be reparented and have init
(process number 1) as its parent. at which point you can no longer tell if it previously had cron
as its parent.
None of this is specific to Python, but maybe check After starting process, how to get parent's PID in the child? for implementation details.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…