ShtukbaseStandard
包文件→ .shtukbase/packages/schedule/actions/cron.ts

actions/cron.ts

13 行, 816 B.

文件按包中的原样显示:代码及其注释不做翻译。

  1. // `shtuk run schedule cron [--every 5]`: prints the crontab line that calls the tick of this project every N minutes.
  2. // It changes nothing: the owner adds the line with `crontab -e`.
  3. import { mkdirSync } from 'node:fs';
  4. import { dirname } from 'node:path';
  5. import { args } from '../../agents/lib/write.ts';
  6. import { shq } from '../../harness/lib/harness.ts';
  7. import { everyArg, host } from '../lib/host.ts';
  8. const a = args(process.argv.slice(2));
  9. const h = host(process.cwd(), everyArg(a.every));
  10. mkdirSync(dirname(h.log), { recursive: true });
  11. console.log(`# The schedule tick of the project ${process.cwd()} every ${h.every} min. To add: crontab -e, paste the line below.`);
  12. console.log(`*/${h.every} * * * * cd ${shq(process.cwd())} && PATH=${shq(h.path)} ${shq(h.bun)} ${shq(h.tick)} >> ${shq(h.log)} 2>&1`);