is there a way to run scripts on host start-up ?

Hell Angel

New Member
May 1, 2019
10
0
1
31
Hello everyone,
I want to run Scripts on host start-up, what should I do ?
this scripts:
Code:
echo 0 > /sys/class/vtconsole/vtcon0/bind
echo 0 > /sys/class/vtconsole/vtcon1/bind
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
I tried:

Code:
#!/bin/sh
nano /etc/init.d/superscript
chmod 755 /etc/init.d/superscript
update-rc.d superscript defaults
but not working automatically, still have to run service start-kvm start ;(
 
Last edited:
I'd edit root's crontab (crontab -e) and add them via: @reboot /path/to/script

I do the same for scripts to let me know if a host reboots, I get a page via Pushover
 
  • Like
Reactions: Hell Angel
Wow, didn't realize it was the upgrade that did that. Was working on sr-iov passthrough for the ethernet 10g and thought I had ruined my config. Thanks again.
 
Sometimes I won't use my Proxmox home server for several days and I want to keep it off.
It has a wake up alarm set on BIOS to power on at 8 am every day. Then it makes a http request from a public server, checks whether the string "POWER=OFF" is present and if so, runs a "shutdown -P 1"
That command though won't work. I've already debugged this script, it's reaching the shutdown command, it's running as root, but somehow the server won't power off.
Any ideas what could be happening?
ps: I have also tried to detach the shutdown command with a & by the end of it.
ps2: If I run it over the command line (remote ssh), it will shutdown gracefully.
 
Hi,

I believe the answer to this specific need is VM hookscripts.

The example Perl script can be found at /usr/share/pve-docs/examples/guest-example-hookscript.pl
, but I believe bash or python can be used to write the needed hook.

The hook script accepts 2 arguments:

Bash:
hookscript "<VM_ID>" "<VM_PHASE>"

I did not test this but

- VM_ID is the integer VM ID.
- VM_PATH is one of pre-start, post-start, pre-stop, post-stop, and maybe others.
 
Last edited:

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!