Perl 脚本中的 CRUD cron 条目

发布于 2024-10-18 04:09:28 字数 607 浏览 3 评论 0原文

是否可以通过用户运行的 perl 脚本来控制用户 crontab 条目?假设我想读取、写入和删除条目。

我查看了 Schedule::Cron 但不太理解它。我假设它与每个用户的实际 crontab 无关,是否正确?

另外,关于 Schedule::Cron,它只是一个必须始终在系统上运行的程序,这是否正确?因此,如果系统关闭然后再次打开,那么它将不会运行(与 cron 不同 - 当然,除非该程序是由不同的系统调度程序(例如 Cron)启动的;在这种情况下,它有什么意义?)

理想情况下,我想在 Windows 系统上使用任务计划程序做同样的事情。

关键是控制调度行为的脚本(无论是 crontab 本身还是行为类似 crontab 的东西)需要能够退出,并且 cron 条目应该保留。这是因为该脚本将在控制 GUI 的事件循环内调用,因此如果用户退出 GUI,程序需要退出,但用户创建的 cron 作业需要保留。同样,如果 GUI 重新启动(并且事件循环重新启动),则应该可以编辑和删除计划任务。

(编辑:Schedule::At 一次性工作在 *Nix 系统上查看业务。然而,仍然在 Windows 上挣扎 - 模块 Win32::AdminMisc 和 Win32:TaskScheduler 不再需要维护)

Is it possible to control user crontab entries from a perl script that is run by that user? Let's say I want to read, write and delete entries.

I've looked at Schedule::Cron and can't quite understand it. Am I correct in assuming it has nothing to do with the actual crontab for each user?

Also, with regard to Schedule::Cron, is it correct that it is simply a program that must always be running on the system? So if system is turned off and on again, then it will not run (unlike cron - unless, of course the program is kicked off by a different system scheduler, like Cron; in that case, what's the point of it?)

Ideally, I'd like to do the same thing on Windows systems with task scheduler.

The key is that the script that controls scheduling behaviour (whether that is the crontab itself or something behaving like the crontab) needs to be able to exit, and the cron entries should remain. This is because the script will be called within an event loop that controls a GUI, so if the user exits the GUI, the program needs to exit, but the cron job that the user created needs to remain. Likewise, if the GUI restarts (and the event loop restarts), it should be possible to edit and delete scheduled tasks.

(EDIT: Schedule::At for one off jobs looks the business on *Nix systems. Still struggling with Windows however - the modules Win32::AdminMisc and Win32:TaskScheduler no longer look to be maintained)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

生生漫 2024-10-25 04:09:28

我能找到的最有前途的选项是 Config::Crontab

Config::Crontab - 读/写 Vixie 兼容的 crontab(5) 文件

请随意尝试在 CPAN 搜索站点。

The most promising option I can find is Config::Crontab.

Config::Crontab - Read/Write Vixie compatible crontab(5) files

Feel free to try searching yourself at the CPAN search site.

咆哮 2024-10-25 04:09:28

There are solutions fow Windows in the Win32 namespace (Win32::TaskScheduler). Out top of my head I don't know of anything that would work cross-platform.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文