@reboot cron 指令在 Solaris 上不起作用?我该用什么来代替?

Ale*_*yne 1 solaris cron

我只是尝试contab -e在 Solaris 服务器上添加此行:

@reboot /root/reboot.sh
Run Code Online (Sandbox Code Playgroud)

该脚本启动 Web 应用程序。但问题是这种语法被拒绝了。

# crontab -e
@reboot /root/reboot.sh
crontab: error on previous line; unexpected character found in line.
crontab: errors detected in input, no crontab file generated.
Run Code Online (Sandbox Code Playgroud)

我猜是因为这是 Solaris?我应该使用什么 cron 语法?

Jam*_*man 5

@reboot类似的@时间值是 Vixie cron 的一个功能。Solaris 使用 System V 版本的 cron。(维基百科参考

本质上,您无法通过调度程序执行您想要的操作,因此需要定期运行的 cron 作业来检查您的服务是否正在运行,或者编写脚本init(或 Solaris 10 的瞬态 SMF 服务)。