Files created or modified less than 48 hours ago
sorted from the newest to the oldest:
find / -mtime -2 -printf "%T@" -ls | sort
I have found %T@
from man find
: last modification time (seconds since epoch)
Given the context of wanting to reboot a Linux system, I would take a multi-pronged approach.
First, disable future logins by creating an /etc/nologin
file. You could leave it blank or enter informative text in there, such as:
"Logins to this system have been temporarily disabled in preparation for a server reboot, scheduled for (time and date). Please try again after (expected end time)."
Don't forget to remove /etc/nologin when you're done!
Additionally, since a reboot will clear all processes, whether they're interactive or not, I would use ps
to look for processes owned by users. This will take some manual investigation to determine whether the processes are worth keeping or not, but should narrow the field some. I've hard-coded 1000 here as the value of UID_MIN from /etc/login.defs as the cutoff for "system" vs "user" UIDs. If any of your users have UIDs below 1000, you'll need to adjust that number.
ps -eo pid,uid,args | awk '$2 >= 1000'
Of course, you could adjust the ps
columns to taste, perhaps to add the translated username and process start time (ps -eo pid,uid,user,start,args
) or others -- just be careful to keep the ps
UID and awk
field in sync with each other.
To get the list of unique user names, use:
ps -eo user,uid | awk 'NR>1 && $2 >= 1000 && ++seen[$2]==1{print $1}'
Best Answer
There's no specific file you can use for this, but it's easy to add your own.
In your
.profile
or.bash_profile
or whatever you could do something likeThe
[[
line is there to preventfind
from complaining if the file doesn't exist.Edit: Ah, sorry, I may have slightly misunderstood your question. You may want to run the command at any time, so in this case you could just have this in your
.bash_profile
And now from the command line
You can reset the timer at any time by
touch
ing the file again.