Cross-platform autostart manager for Windows Task Scheduler and Linux Supervisor
Project description
autostartd
自动启动管理工具,支持 Windows 任务计划程序与 Linux Supervisor。提供统一的交互式菜单,帮助你配置脚本或可执行文件自启动。
安装
pip install autostartd
如需 pyre_tools 菜单能力,再额外安装:
pip install "autostartd[tools]"
运行
autostartd
任何输入处输入 q 可退出当前流程返回菜单。
功能
- Windows:通过
schtasks创建、更新、查询、删除任务。 - Windows 支持
.exe、.py、.bat、.cmd、.ps1。 - Windows 可选择登录后自启或登录前自启。
- Linux:通过 Supervisor 创建、查询、删除项目。
- Linux 支持
.py、.sh、.bash、.run、可执行文件、alias、原始命令、roslaunch、pip 工具命令和python -m模块命令。 - Linux 可选择登录前自启或登录后自启。
- Linux 创建时可选择“立即生效”或“仅下次开机/登录后生效”。
- Linux 会在首次 sudo 成功后缓存密码到
~/.autostartd/config.json,后续复用;若失效会提示重新输入并更新缓存。 - Linux 提供基础管理菜单,可查看项目状态并启动、停止、重启、禁用自启、恢复自启。
- 支持中英文界面切换,语言配置保存到
~/.autostartd/config.json。
自启动时机
Windows
- 登录后自启:创建
ONLOGON任务,使用当前用户运行,通常不需要管理员权限。 - 登录前自启:创建
ONSTART任务,使用SYSTEM账户和最高权限运行,需要在管理员终端运行。
Linux
- 登录前自启:使用系统级 Supervisor,配置写入
/etc/supervisor/conf.d/,需要 sudo。Supervisor 服务会尽量通过systemctl enable --now supervisor启用。 - 登录后自启:使用用户级 supervisord,配置写入
~/.config/autostartd/supervisor/,并在~/.profile中添加启动用户 supervisord 的片段。具体进程仍由 Supervisor 管理。 - 新增/修改项目时,可选择立即启动,或者只保存配置让它在下次开机/登录后生效。
WSL 中推荐启用 systemd 后使用登录前自启;如果不启用 systemd,可以使用登录后自启,用户登录 shell 后会启动用户级 supervisord。
Linux 启动类型
新增 Linux Supervisor 项目时可以选择启动类型:
- 自动识别脚本/可执行文件:
.py会用当前 Python,.sh/.bash会用/bin/bash,.run或无扩展名可执行文件会直接运行。 - Shell/alias/原始命令:自动包装为
bash -lc,并加载~/.bashrc、~/.bash_profile,适合 alias、自定义命令、带管道或环境变量的命令。 - ROS roslaunch:输入包名和 launch 文件,自动包装为
roslaunch package file.launch ...。 - ROS roslaunch 会通过
bash -lc加载常见 ROS 环境,并以前台主进程方式运行,降低 SupervisorBACKOFF概率。 - pip 工具:输入命令名和参数,例如
uvicorn app:app --host 0.0.0.0。 - Python 模块:自动包装为
python -m module ...。
API 调用
from autostartd import set_autostart, remove_autostart, list_autostart
# start_mode 可选:
# "after_login"
# "before_login"
set_autostart(
"my_task",
"~/Downloads/test_auto_start.py",
overwrite=True,
sudo_password="your_sudo_password",
start_mode="before_login",
)
set_autostart(
"ros_task",
"my_robot bringup.launch",
command_type="roslaunch",
start_mode="before_login",
sudo_password="your_sudo_password",
run_immediately=False,
)
set_autostart(
"alias_task",
"my_alias --flag",
command_type="alias",
start_mode="after_login",
)
print(list_autostart("my", sudo_password="your_sudo_password", start_mode="before_login"))
remove_autostart("my_task", sudo_password="your_sudo_password", start_mode="before_login")
说明:
- Windows 不需要
sudo_password。 - Linux
before_login需要sudo_password。 - 若之前已经通过交互模式缓存过 sudo 密码,API 也可以复用该缓存。
- Linux
after_login不需要 sudo,但需要当前用户登录后启动用户级 supervisord。
依赖
- Windows:系统自带
schtasks。 - Linux:需要
supervisord与supervisorctl。Ubuntu/Debian 会尝试通过apt-get install supervisor自动安装;CentOS/RHEL 会尝试使用dnf或yum。 - 首次自动安装 Supervisor 时会显示
tqdm进度条。 pyre_tools为可选依赖,仅在需要菜单中的Run pyre_tools功能时安装。- Python:3.8+。
autostartd
Cross-platform autostart manager for Windows Task Scheduler and Linux Supervisor.
Features
- Windows task management via
schtasks. - Windows supports
.exe,.py,.bat,.cmd, and.ps1. - Windows supports after-login and before-login startup.
- Linux process management via Supervisor.
- Linux supports
.py,.sh,.bash,.run, executable files, aliases, raw commands,roslaunch, pip tool commands, andpython -mmodule commands. - Linux supports before-login system Supervisor and after-login user supervisord.
- Linux can either apply a new task immediately or only on the next boot/login.
- Linux caches a validated sudo password in
~/.autostartd/config.jsonand asks again only if the saved credential fails. - Linux includes a basic management menu to start, stop, restart, disable autostart, and re-enable autostart.
Startup Timing
- Windows after login: creates an
ONLOGONtask for the current user. - Windows before login: creates an
ONSTARTtask asSYSTEM; run autostartd from an administrator terminal. - Linux before login: writes system Supervisor config under
/etc/supervisor/conf.d/; sudo is required. - Linux after login: writes user Supervisor config under
~/.config/autostartd/supervisor/and starts user supervisord from~/.profile.
API
from autostartd import set_autostart, remove_autostart, list_autostart
set_autostart("my_task", "/path/to/app.py", start_mode="before_login", sudo_password="password")
set_autostart("ros_task", "my_pkg bringup.launch", command_type="roslaunch", start_mode="before_login", sudo_password="password")
set_autostart("tool_task", "uvicorn app:app --host 0.0.0.0", command_type="pip", start_mode="after_login")
print(list_autostart("my", start_mode="before_login", sudo_password="password"))
remove_autostart("my_task", start_mode="before_login", sudo_password="password")
Installation Notes
pip install autostartd
Install the optional pyre_tools integration only if you need that menu action:
pip install "autostartd[tools]"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autostartd-0.1.4.tar.gz.
File metadata
- Download URL: autostartd-0.1.4.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb0109ee0f4c3a629042bc858e2100fda96739f7928ad11997cdadc207a419cd
|
|
| MD5 |
80382ec7c7f9e19a1a748d32f9086297
|
|
| BLAKE2b-256 |
2b6dd5bc3af9a844997e80d51691ae7ac250feeeb7a934e8eaa093e85e6cc7ca
|
File details
Details for the file autostartd-0.1.4-py3-none-any.whl.
File metadata
- Download URL: autostartd-0.1.4-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6491e5be53f8a8e32692777c11475ba9b48c89c82f215781a578605b3e280568
|
|
| MD5 |
2eff7cf7fca39b7a774e155ba08a5bc2
|
|
| BLAKE2b-256 |
e0a0479c56955ebc8b5614aa7fc1533e29c71be085e4ced775ef16935af5574a
|