node.js - 这些 Node 生成的 CronJobs 存储在哪里?
问题描述
我使用以下代码使用cron创建了 CronJobs ,但是我找不到它们来销毁它们。在 Debian BullsEye 上,我检查了 /etc/crontab、/etc/cron.d、/etc/cron.daily、/etc/cron.weekly、/etc/cron.monthly 并没有任何内容。
此进程在 www-data 下运行
new cronjob('* ' + sMarr[i] + ' ' + sHarr[i] + ' * * *', function(x) {
shell.exec('ffmpeg -hide_banner -loglevel warning -i '+iUarr[x]+' -c:a aac -t 00:'+dMarr[x]+':'+dSarr[x]+' -f hls /mnt/streamlinks/'+outputName+'.m3u8&', {async:true});
}.bind(null, i), null, true, 'Europe/London').start();
console.log("made cron job");
}catch{
console.log("Error creating cronjob");
}
提前致谢。
解决方案
这些 cron 作业是在内存中创建的,它们不是在系统级别创建的。这允许模块在不同的操作系统(例如 Windows)上工作。
创建作业时,您可以保留对它的引用,然后使用 job.stop() 随时停止它。
const CronJob = require('cron').CronJob;
const job = new CronJob('* * * * * *', function() {
console.log('Sample cron job...');
}, null, false);
// Start the cron job...
job.start();
setTimeout(() => {
console.log("Stopping cron job..");
// Kill the cron job
job.stop();
}, 10000)
推荐阅读
- c - 如何修复“函数的隐式声明”
- java - 如果安装了 Nvidia 或 AMD GPU 卡,则获取 bool
- pandas - Pandas 识别出产生 80 次销售额的商品数量
- c# - 如何在不破坏 MVVM 的情况下从 ViewModel 通知 View?
- python - Google assistant sdk [CUSTOM TYPES]:从自定义操作中捕获货币价值(10 美元、20 美元、50 美元)
- python - 如何在 gdb 中使用 __slots__ 读取 python 对象的属性
- sql-server - 由于大量重复而没有主键的表,试图加快我的查询以消除重复等
- c# - xamarin 表单中的弯曲底部导航栏
- fluentvalidation - .NET CORE API:是否可以根据用于提交模型的 http 动词有条件地验证模型?
- html - 如何做一个完美的圆圈