Answer the question
In order to leave comments, you need to log in
Determine whether the user has run a script?
Hello.
There is Arch Linux (it is desirable that it would work on all distros) and there is a python script.
It is required to determine whether the script is running from the user shell (from under the root) or by the cron (the cron is also root). Are there any differences in the environment that can help solve this problem?
Thank you.
Answer the question
In order to leave comments, you need to log in
https://docs.python.org/2/library/getpass.html
import getpass
current_user = getpass.getuser()
Write a cron script with a parameter and check for the presence of the parameter.
Hello.
>> It is required to define the script is started from...
Who needs to define? the script itself must determine how it is launched, or should it be determined by some other left script??
One way or another, scripts run from a logged in user and cron will differ in the set of environment variables, so try using them, for example SHLVL (variables are stored in /proc/$$/environ).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question