LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

遅延実行

Posted at

遅延実行する

コミット

変数未設定の場合即時実行されるので注意すること

5時間遅延.zsh
TMP_DELAY_H=5 && TMP_COMMIT_MSG="なんらかの コミットメッセージ"

sleep $((TMP_DELAY_H * 60 * 60)) \
  && git commit -m $TMP_COMMIT_MSG \
  && git push

ブラウザ操作

タイマー付き遅延関数.js
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
const delay = async function(f, m) {
    for (i = 1; i <= m; ++i) {
        await sleep(6e4);
        console.log(`\u001b[36m${i}分\u001b[0m経過`);
    }
    console.log('=== \u001b[31m実行\u001b[0m ===');
    f();
};
delay(() => {
    // 処理を書く
}, 5); // 5分後に実行
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up