継続的に電源がオンになっていないコンピューターで cron ジョブをスケジュールしますか?

継続的に電源がオンになっていないコンピューターで cron ジョブをスケジュールしますか?

毎月 1 日にスクリプトを実行したいです。
コンピューターの電源がオフになっている場合は、次回電源を入れたときにスクリプトを実行したいと思います。

Anacron は「電源オフ」の使用例には適していますが、日次、週次、月次間隔のみを提供します。月次では遅すぎ、週次では早すぎます。

fcron をチェックしましたが、そのパッケージは Timeshift と競合するため、これは選択肢になりません。

cron が毎月 1 日から 4 日の間の任意の時間にタスクを 1 回実行できれば、それも問題ないと考えていました。cron 構文を確認したところ、実際には不可能だと思いました。

これを解決する方法を誰か知っていますか?

私はArch Linux (Manjaro) を使用しています。

答え1

このようなもの (未テスト

#!/bin/bash
# run this via crontab on days 1-4 and @reboot
#
# Store the run_month here, or somewhere writable on disk not /tmp
runfile="$HOME/run_month"
# make sure $runfile exists, initalize to a non-month if 1st run ever 
[[ ! -f "$runfile" ]] && echo "init" >"$runfile"
#
# get the last month we ran
rf="$(cat "$runfile")"
# get the current month
cm="$(date "+%b")"
# if $rf is the same as $cm, quit
if [[ "$cm" = "$rf" ]] ; then
  exit
fi
# Remember we ran this month
echo "$cm" >"$runfile"
#
# Left  as an exercise for the student 

関連情報