My question now is mentioned at the title:
How to know how my script is being executed? (Manual/System like cron/other scripts)?
I wish you guys could help me. I have this long issue trying to know how a script is being executed and by who.
You can get the parent PID with
Then finding the parent process name from its PID is non-portable. On linux/unix you could run the
ps command and parse the output. On Windows you'll probably need something like
Win32::Process::List. No idea for OSX or other operating systems, try Googling perl get process name from pid.