我有以下内容:
#! /usr/bin/python3.7
f=open("python_out.txt",'w',encoding='utf-8')
f.write("OK1")
import socket
import telegram
f.write("OK2")
BOT_TOKEN = "telegram BOT_TOKEN"
CHAT_ID = "chat_id"
bot = telegram.Bot(token=BOT_TOKEN)
host_name = socket.gethostname()
content = 'Machine name: %s is shutting down!' % host_name
bot.send_message(chat_id=CHAT_ID, text=content)
f.write("OK3")
python3 script.py
我已经检查了我的环境,当它在实例中时,我可以让这个脚本工作,它可以发送通知和输出python_out.txt
。
我将此脚本设置为shutdown-script
但是当我手动单击“停止”按钮时,它没有按预期工作。startup-script
也。
我读过很多帖子:
当然也包括官方文档:
我想尝试设置powerbtn.sh/etc/acpi/
,但在 GCP Ubuntu 16.04 LTS 中找不到
我找不到更多的时间表,有什么想法吗?