Skip to main content
added 84 characters in body
Source Link
gapsf
  • 624
  • 4
  • 7

Create two systemd units and one script.

First unit:

/etc/systemd/system/are-users-logged.timer [Unit] Description=Start check for logged users [Timer] OnBootSec=15min Unit=shutdown-ifno-logged-users [Install] WantedBy=timers.target 

runs shutdown-ifno-logged-users.service once after 15min from the boot.

Second unit:

/etc/systemd/system/shutdown-ifno-logged-users.service [Unit] Description=Shutdown if there are no logged users [Service] Type=oneshot User=root ExecStart=script_to_check_logged_users 

starts your script to check logged users.

In your script parse output of loginctl --no-pager list-users or maybe even who -q and shutdown if there is no user logged.

ToIf you want to prevent reboot if you loginonce somebody logged in and then logout before timer is triggeredlogged out before timer is triggered you may try to stop are-users-logged.timer from ~./etc/profile.d/somescript.sh with something like sudo systemctl stop are-users-logged.timer. But i guess it is maybymaybe problematic if user is not root due password asking.

Better create some file in /tmp with echo from ~./etc/profile.d/somescript.sh to indicate you aresomebody was logged and check in your script_to_check_logged_users if it exists and skip shutdown.

Create two systemd units and one script.

First unit:

/etc/systemd/system/are-users-logged.timer [Unit] Description=Start check for logged users [Timer] OnBootSec=15min Unit=shutdown-ifno-logged-users [Install] WantedBy=timers.target 

runs shutdown-ifno-logged-users.service once after 15min from the boot.

Second unit:

/etc/systemd/system/shutdown-ifno-logged-users.service [Unit] Description=Shutdown if there are no logged users [Service] Type=oneshot User=root ExecStart=script_to_check_logged_users 

starts your script to check logged users.

In your script parse output of loginctl --no-pager list-users or maybe even who -q and shutdown if there is no user logged.

To prevent reboot if you login and then logout before timer is triggered you may try to stop are-users-logged.timer from ~./profile with something like sudo systemctl stop are-users-logged.timer. But i guess it is mayby problematic due password asking.

Better create some file in /tmp with echo from ~./profile to indicate you are was logged and check in your script_to_check_logged_users if it exists and skip shutdown.

Create two systemd units and one script.

First unit:

/etc/systemd/system/are-users-logged.timer [Unit] Description=Start check for logged users [Timer] OnBootSec=15min Unit=shutdown-ifno-logged-users [Install] WantedBy=timers.target 

runs shutdown-ifno-logged-users.service once after 15min from the boot.

Second unit:

/etc/systemd/system/shutdown-ifno-logged-users.service [Unit] Description=Shutdown if there are no logged users [Service] Type=oneshot User=root ExecStart=script_to_check_logged_users 

starts your script to check logged users.

In your script parse output of loginctl --no-pager list-users or maybe even who -q and shutdown if there is no user logged.

If you want to prevent reboot once somebody logged in and then logged out before timer is triggered you may try to stop are-users-logged.timer from /etc/profile.d/somescript.sh with something like sudo systemctl stop are-users-logged.timer. But i guess it is maybe problematic if user is not root due password asking.

Better create some file in /tmp with echo from /etc/profile.d/somescript.sh to indicate somebody was logged and check in your script_to_check_logged_users if it exists and skip shutdown.

added 375 characters in body
Source Link
gapsf
  • 624
  • 4
  • 7

Create two systemd units and one script.

First unit:

/etc/systemd/system/are-users-logged.timer [Unit] Description=Start check for logged users [Timer] OnBootSec=15min Unit=shutdown-ifno-logged-users [Install] WantedBy=timers.target 

runs shutdown-ifno-logged-users.service once after 15min from the boot.

Second unit:

/etc/systemd/system/shutdown-ifno-logged-users.service [Unit] Description=Shutdown if there are no logged users [Service] Type=oneshot User=root ExecStart=script_to_check_logged_userExecStart=script_to_check_logged_users 

starts your script to check logged users.

In your script parse output of loginctl --no-pager list-users or maybe even who -q and shutdown if there is no user logged.

To prevent reboot if you login and then logout before timer is triggered you may try to stop are-users-logged.timer from ~./profile with something like sudo systemctl stop are-users-logged.timer. But i guess it is mayby problematic due password asking.

OrBetter create some file in /tmp with echo frome echo from ~./profile to indicate you are was logged and check in your script_to_check_logged_userscript_to_check_logged_users if it exists and skip shutdown.

Create two systemd units and one script.

First unit:

/etc/systemd/system/are-users-logged.timer [Unit] Description=Start check for logged users [Timer] OnBootSec=15min Unit=shutdown-ifno-logged-users [Install] WantedBy=timers.target 

runs shutdown-ifno-logged-users.service once after 15min from the boot.

Second unit:

/etc/systemd/system/shutdown-ifno-logged-users.service [Unit] Description=Shutdown if there are no logged users [Service] Type=oneshot User=root ExecStart=script_to_check_logged_user 

starts your script to check logged users.

In your script parse output of loginctl --no-pager list-users or maybe even who -q and shutdown if there is no user logged.

To prevent reboot if you login and then logout before timer is triggered you may try to stop are-users-logged.timer from ~./profile with something like sudo systemctl stop are-users-logged.timer. But i guess it is problematic.

Or create some file in /tmp with echo frome ~./profile to indicate you are was logged and check in your script_to_check_logged_user if it exists and skip shutdown.

Create two systemd units and one script.

First unit:

/etc/systemd/system/are-users-logged.timer [Unit] Description=Start check for logged users [Timer] OnBootSec=15min Unit=shutdown-ifno-logged-users [Install] WantedBy=timers.target 

runs shutdown-ifno-logged-users.service once after 15min from the boot.

Second unit:

/etc/systemd/system/shutdown-ifno-logged-users.service [Unit] Description=Shutdown if there are no logged users [Service] Type=oneshot User=root ExecStart=script_to_check_logged_users 

starts your script to check logged users.

In your script parse output of loginctl --no-pager list-users or maybe even who -q and shutdown if there is no user logged.

To prevent reboot if you login and then logout before timer is triggered you may try to stop are-users-logged.timer from ~./profile with something like sudo systemctl stop are-users-logged.timer. But i guess it is mayby problematic due password asking.

Better create some file in /tmp with echo from ~./profile to indicate you are was logged and check in your script_to_check_logged_users if it exists and skip shutdown.

added 375 characters in body
Source Link
gapsf
  • 624
  • 4
  • 7

Create two systemd units and one script.

First unit:

/etc/systemd/system/are-users-logged.timer [Unit] Description=Start check for logged users [Timer] OnBootSec=15min Unit=shutdown-ifno-logged-users [Install] WantedBy=timers.target 

runs shutdown-ifno-logged-users.service once after 15min from the boot.

Second unit:

/etc/systemd/system/shutdown-ifno-logged-users.service [Unit] Description=Shutdown if there are no logged users [Service] Type=oneshot User=root ExecStart=script_to_check_logged_user 

starts your script to check logged users.

In your script parse output of loginctl --no-pager list-users or maybe even who -q and shutdown if there is no user logged.

To prevent reboot if you login and then logout before timer is triggered you may try to stop are-users-logged.timer from ~./profile with something like sudo systemctl stop are-users-logged.timer. But i guess it is problematic.

Or create some file in /tmp with echo frome ~./profile to indicate you are was logged and check in your script_to_check_logged_user if it exists and skip shutdown.

Create two systemd units and one script.

First unit:

/etc/systemd/system/are-users-logged.timer [Unit] Description=Start check for logged users [Timer] OnBootSec=15min Unit=shutdown-ifno-logged-users [Install] WantedBy=timers.target 

runs shutdown-ifno-logged-users.service once after 15min from the boot.

Second unit:

/etc/systemd/system/shutdown-ifno-logged-users.service [Unit] Description=Shutdown if there are no logged users [Service] Type=oneshot User=root ExecStart=script_to_check_logged_user 

starts your script to check logged users.

In your script parse output of loginctl --no-pager list-users or maybe even who -q and shutdown if there is no user logged.

Create two systemd units and one script.

First unit:

/etc/systemd/system/are-users-logged.timer [Unit] Description=Start check for logged users [Timer] OnBootSec=15min Unit=shutdown-ifno-logged-users [Install] WantedBy=timers.target 

runs shutdown-ifno-logged-users.service once after 15min from the boot.

Second unit:

/etc/systemd/system/shutdown-ifno-logged-users.service [Unit] Description=Shutdown if there are no logged users [Service] Type=oneshot User=root ExecStart=script_to_check_logged_user 

starts your script to check logged users.

In your script parse output of loginctl --no-pager list-users or maybe even who -q and shutdown if there is no user logged.

To prevent reboot if you login and then logout before timer is triggered you may try to stop are-users-logged.timer from ~./profile with something like sudo systemctl stop are-users-logged.timer. But i guess it is problematic.

Or create some file in /tmp with echo frome ~./profile to indicate you are was logged and check in your script_to_check_logged_user if it exists and skip shutdown.

added 11 characters in body
Source Link
gapsf
  • 624
  • 4
  • 7
Loading
added 23 characters in body
Source Link
gapsf
  • 624
  • 4
  • 7
Loading
added 23 characters in body
Source Link
gapsf
  • 624
  • 4
  • 7
Loading
added 23 characters in body
Source Link
gapsf
  • 624
  • 4
  • 7
Loading
Post Undeleted by gapsf
added 262 characters in body
Source Link
gapsf
  • 624
  • 4
  • 7
Loading
Post Deleted by gapsf
Source Link
gapsf
  • 624
  • 4
  • 7
Loading