Sleeping the display - cron?

hutchwilco

Member
Apr 15, 2020
9
1
23
42
Hi all, new Proxmox user here.

I've tentatively installed PVE on a 2011 Macbook Pro (dedicated graphics card is dead, so perfect cheap server).
I've modified logind.conf to ignore the lidswitch when I close the lid, but the display remains on (I can see the backlight).
I'd like to have this time out ie turn off after some minutes of disuse.

I get the desired outcome if I login and run setterm -blank 1.

However this doesn't persist past a reboot. Referencing this post, I thought I'd use [USER=28815]@reboot[/USER] /path/to/script.sh in crontab.
This doesn't seem to work either. Yes I made the script executable, and confirmed it worked at the terminal.

Does anyone have any ideas for either a better way to do this or what I'm doing wrong?

Thanks
 
Check this answer, in short setting 'consoleblank=600' on the kernel command line should turn off the screen after 10 minutes (adjustable, in seconds) of no use...
 
Check this answer, in short setting 'consoleblank=600' on the kernel command line should turn off the screen after 10 minutes (adjustable, in seconds) of no use...

Stefan, thank you for your pointers. I tried very hard to logically pursue the linked instructions, however have not had success. I'll summarise my steps in case someone can point out where I've gone wrong:
Reading your first link, I resolved to first determine my bootloader type, either Grub or Systemd as per:
Grub
The kernel commandline needs to be placed in the variable GRUB_CMDLINE_LINUX_DEFAULT in the file /etc/default/grub. Running update-grub appends its content to all linux entries in /boot/grub/grub.cfg.
Systemd-boot
The kernel commandline needs to be placed as one line in /etc/kernel/cmdline. To apply your changes, run pve-efiboot-tool refresh, which sets it as the option line for all config files in loader/entries/proxmox-*.conf.

Since /etc/default/grub did not exist on my system, I presumed I should pursue the systemd pathway.
I created the cmdline file with consoleblank=60, and ran pve-efiboot-tool refresh.
All ok, though there was nothing "loader/entries/proxmox-*.conf" related anywhere on my system that I could find to confirm my changes.
Unfortunately, after a reboot this did not set a timeout on the display. Indeed, the consoleblank system variable was "0" after boot. In fact, before I made the changes above, it was =60, which I presume was set from my effort to use setterm -blank 1.

I endeavoured to determine for certain what my bootloader type was, trying file -s /dev/sda and file -sk /dev/sda, however none of these gave me information one way or the other, instead confusing me more by apparently saying the disk has DOS/MBR boot record. For the record, I installed Proxmox on the Macbook Pro from a USB installer with Proxmox 6.1 ISO. Previous to that the Macbook Pro had OSX installed.

I appreciate any answer or advice anyone may have.
For clarity, one possible answer that would work for me is answering the question "what is the correct way to add "setterm -blank 1" to a boot config/init script that will run and apply to Proxmox host on boot/reboot? That is, without logging in at the local terminal."
 
When you run pve-efiboot-tool refresh, does it say 'Copying and configuring kernels on /dev/disk/by-uuid/XXX' ? If not, your are using GRUB. systemd-boot is only used when ZFS is used as the root filesystem on a UEFI booted system.

/etc/default/grub should always exist though, even if it is not used. It not existing is definitely weird.

Anyway, to see if your commandline entry is applied you can check /proc/cmdline, that shows the currently booted kernel arguments.

For clarity, one possible answer that would work for me is answering the question "what is the correct way to add "setterm -blank 1" to a boot config/init script that will run and apply to Proxmox host on boot/reboot? That is, without logging in at the local terminal."
So technically auto-start can be acomplished using a simple systemd service service file (search systemd autostart online, there's many examples out there), or alternatively via a @ reboot crontab entry. However: 'setterm' is probably not going to work well that way, since it requires to be run in a terminal AFAIK - so I'm not sure of an easy way to run it automatically.
 
Stefan, thanks for your further guidance.

When you run pve-efiboot-tool refresh, does it say 'Copying and configuring kernels on /dev/disk/by-uuid/XXX' ? If not, your are using GRUB. systemd-boot is only used when ZFS is used as the root filesystem on a UEFI booted system.

/etc/default/grub should always exist though, even if it is not used. It not existing is definitely weird.
Your tips helped me indeed work out that my system is grub. As an explainer, I was thrown by the output from the pve-efiboot-tool command being more than just "error", instead outputting several obtuse lines and subtly saying nothing meaningful happened.

And the existence of grub in /etc/default.... ? Well I'll just put that down to a "brainfart". It was there all along.

For others with grub-bootloader systems, wanting to set a display or screen power off time by default, (and who need a similar level of explainer ):
1. Open /etc/default/grub to edit, using nano or other editor.
2. add consoleblank=600 (or other number in seconds) to the variable GRUB_CMDLINE_LINUX_DEFAULT. If you have existing parameters for that variable, just add a space and then your variable eg GRUB_CMDLINE_LINUX_DEFAULT="quiet consoleblank=30". Save and exit the editor.
3. run update-grub to append that new config to the actual grub.cfg file found at /boot/grub/.
4. reboot. Check the new command is loaded by looking for it with cat /proc/cmdline. Also, obviously you can wait to see if your display turns off.

alternatively via a @ reboot crontab entry. However: 'setterm' is probably not going to work well that way, since it requires to be run in a terminal AFAIK - so I'm not sure of an easy way to run it automatically.
Indeed, @reboot crontab was what I tried first - both calling an executable shell script and directly including setterm -blank 1 in the crontab command. No dice though.

Thanks again Stefan
 
  • Like
Reactions: Stefan_R

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!