Skip to main content

Cross-platform autostart manager for Windows Task Scheduler and Linux Supervisor

Project description

autostartd

自动启动管理工具,支持 Windows 任务计划程序与 Linux Supervisor。提供统一的交互式菜单,帮助你配置脚本或可执行文件自启动。

安装

pip install autostartd

运行

autostartd

任何输入处输入 q 可退出当前流程返回菜单。

功能

  • Windows:通过 schtasks 创建、更新、查询、删除任务。
  • Windows 支持 .exe.py.bat.cmd.ps1
  • Windows 可选择登录后自启或登录前自启。
  • Linux:通过 Supervisor 创建、查询、删除项目。
  • Linux 支持 .py.sh.bash.run、可执行文件、alias、原始命令、roslaunch、pip 工具命令和 python -m 模块命令。
  • 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 ...
  • 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",
)

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
  • Linux after_login 不需要 sudo,但需要当前用户登录后启动用户级 supervisord。

依赖

  • Windows:系统自带 schtasks
  • Linux:需要 supervisordsupervisorctl。Ubuntu/Debian 会尝试通过 apt-get install supervisor 自动安装;CentOS/RHEL 会尝试使用 dnfyum
  • 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, and python -m module commands.
  • Linux supports before-login system Supervisor and after-login user supervisord.

Startup Timing

  • Windows after login: creates an ONLOGON task for the current user.
  • Windows before login: creates an ONSTART task as SYSTEM; 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")

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

autostartd-0.1.3.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autostartd-0.1.3-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file autostartd-0.1.3.tar.gz.

File metadata

  • Download URL: autostartd-0.1.3.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for autostartd-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5b0698b07ec0466ba4f9be55ede35cdc71c2aea25fc0f371c07dfe835a82e642
MD5 1a6394037439bfa7c410e1773331a0ea
BLAKE2b-256 9439f626ac6e1ce81f9aa7d0c2f6325fc1abb80906020bbdb8c3bfbc68c41e8c

See more details on using hashes here.

File details

Details for the file autostartd-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: autostartd-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for autostartd-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1fb9007726f8d1ed969457016638bba9412c6e6436adca47ec587403e4bd82da
MD5 d56efdb767e5f8d5d65892e1535371f8
BLAKE2b-256 b17be574323b21c4b37a80a9bf6d2871b221b4cfdd1fb19fe01a76b427bb3f2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page