Jump to content

Logins that expire after inactivity instead of 12 hours?

  • Please log in to reply
2 replies to this topic

#1 Zeblote



  • Members
  • PipPip
  • 19 posts

Posted 12 May 2018 - 02:15 PM

I'm wondering if it's possible to expire the login after a few hours of inactivity instead of a fixed time.

With default settings the login just randomly expires even if I was currently doing something - this is even worse when working with unreal engine, since the editor plugin can't handle this correctly and the whole thing needs to be restarted.

#2 Sambwise


    Advanced Member

  • Members
  • PipPipPip
  • 1190 posts

Posted 15 May 2018 - 05:24 PM

The idea of the default 12 hour timeout is that your work day is less than 12 hours long -- i.e. if you start working at 9am you'll login at that time, your ticket will expire at 9pm, and you'll login first thing next morning.  If your work day is actually more like 16 hours long maybe the fix is to make the timeout 20 hours instead?

If you want it to be activity-based you'll need to Macgyver something yourself -- you could give yourself an unlimited timeout and then set up some sort of activity-monitoring system (depends how you define "activity" -- running Perforce commands?  Being at your computer?) to "p4 logout" you after that period.

#3 UnstoppableDrew


    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 10 October 2018 - 05:59 PM

This is admittedly a total hack that will fill your server logs with unnecessary logout commands, but it does accomplish the stated goal. It could be run as a cron job and would need to be run as a user with Perforce superuser level access. How often you run it would depend on how fuzzy the idle timeout is. As written it's a 3-hour window. If you want to be strict, run the cron job every 5 min and deal with the logfile explosion. Or run it every hour with the understanding that the effective idle time is going to be between 3-4 hours. Make it too short and your users will hate you as they have to login several times a day. Note that I'm just echoing the logout command here so I could run it without actually logging everyone out.

now=$(date +"%s")
cutoff=$((now - 3600 * 3))
p4 -ztag -F "%User% %Access%" users | while read line
  user=$(echo $line | cut -d " " -f 1)
  access=$(echo $line | cut -d " " -f 2)
  if [[ $access -lt $cutoff ]]; then
	echo "p4 logout -a $user"

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users