简体   繁体   English

如何在 Linux 上启动时运行 shell 命令?

[英]How do I run a shell command on startup on Linux?

Im using WSL and want run the shell command "export DISPLAY=:0" on startup so I can use gui applications.我正在使用 WSL 并希望在启动时运行 shell 命令“export DISPLAY=:0”,这样我就可以使用 gui 应用程序。 How do I do this?我该怎么做呢?

You can use cron job to run shell automatically, (but cron service will not auto start when startup, you can use Windows Task Scheduler to auto start cron service, or you can create a ink file %sudo ALL=NOPASSWD: /etc/init.d/cron start )您可以使用 cron 作业自动运行 shell,(但 cron 服务在启动时不会自动启动,您可以使用 Windows 任务调度程序自动启动 cron 服务,也可以创建一个墨迹文件%sudo ALL=NOPASSWD: /etc/init.d/cron start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM