How to schedule command execution 1 month from now?

Discussion in 'Command Line' started by postcd, May 4, 2014.

  1. postcd

    postcd Member

    Messages:
    65
    Likes Received:
    5
    Trophy Points:
    8
    Hello,

    whats the fastest way to execute certain command with like X days or month delay?

    i mean like:


    delay -d 30 "rm -rf /root/scriptname.sh"

    is there anything like that?
  2. ZZs

    ZZs Active Member

    Messages:
    136
    Likes Received:
    50
    Trophy Points:
    28
  3. postcd

    postcd Member

    Messages:
    65
    Likes Received:
    5
    Trophy Points:
    8
    thx, alas I did not found answer on yours linked page and also i found "at" but i dont understand its manual and usage for my really simple question - puprose.
  4. ZZs

    ZZs Active Member

    Messages:
    136
    Likes Received:
    50
    Trophy Points:
    28
    at 8pm +30 days
    at>rm -rf /root/scriptname.sh
    at> "ctrl+d" to close

    or
    at 8pm jun 05
    at>rm -rf /root/scriptname.sh
    at> "ctrl+d" to close

    I use a one liner to call a simple script that contains the commands I want executed:
    at -f /home/zz/bin/chkup2 17:15 may 9

    atq will show you the jobs scheduled.

    at my need to be installed and atd must be running (run atd as service so its up and ready.)

    Do a test then read the man page again to learn more options.

    If the schedule needs to be repeated often read up on cron.
    ryanvade likes this.
  5. ryanvade

    ryanvade Administrator Staff Member Staff Writer

    Messages:
    1,260
    Likes Received:
    430
    Trophy Points:
    83
  6. Kovax

    Kovax Member

    Messages:
    34
    Likes Received:
    18
    Trophy Points:
    8
    cron would be the best way to go.
  7. Pantek Support

    Pantek Support New Member

    Messages:
    6
    Likes Received:
    3
    Trophy Points:
    1
    We also recommend using cron for items schedule so far in advance. You can typically place a new file in /etc/cron.d directory (called for example "deleteinthirty") containing something like the following, which would schedule it literally 30 days from today (on 8/8/2014) and automatically remove itself when done.

    01 01 08 08 * rm -rf /root/scriptname.sh ; rm -f /etc/cron.d/deleteinthirty
    Rodrigo likes this.

Share This Page