Linux:在前台运行 cron 作业 [英] Linux: Run cron job in foreground
本文介绍了Linux:在前台运行 cron 作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Linux 中,有没有办法在前台(或交互模式)运行 cron 作业?(我有一个程序会定期运行以接受用户输入并进行一些处理.所以我想将其安排为可以在前台运行的 cron 作业).
In Linux, is there a way to run a cron job in the foreground (or interactive mode)? (I have a program that runs periodically to accept user input and do some processing. So I want to schedule it as a cron job that can run in the foreground).
推荐答案
在您用户的 crontab
上试试这个:
Try this out on your user's crontab
:
@hourly DISPLAY=:0 xterm -e /path/to/my/script.sh
它将在您的脚本执行时打开(每小时)一个 xterm
,并在您的脚本退出后退出.当然,您应该修改 @hourly
部分以满足您的需要.
It will open (hourly) an xterm
with your script executing, and exit after your script exits. Of course, you should modify the @hourly
part to suit your needs.
这篇关于Linux:在前台运行 cron 作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文