Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED Cron Job execute curl only if file has been modified

Discussion in 'General Discussion' started by nrcjea001, Nov 20, 2018.

Tags:
  1. nrcjea001

    nrcjea001 Registered

    Joined:
    Nov 17, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Mauritius
    cPanel Access Level:
    Website Owner
    Hi

    I need to execute a command in cron job, but only if a file has been touched. Currently, my cron command is: curl "..." where "..." is my target link. I am new to this but I did manage to find something online. Hoping that someone with experience can confirm that the command below is correct:

    PHP:
    usr/local/bin/php [/tmp/.lastupdate -nt /my_dir_name/my_filename ] || (curl "https://...index.php?controller..." touch /tmp/.lastupdate)
    Thank You.
     
  2. nrcjea001

    nrcjea001 Registered

    Joined:
    Nov 17, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Mauritius
    cPanel Access Level:
    Website Owner
    Figured it out:

    Code:
     [ /tmp/lastupdate -nt /my_dir_name/my_filename ] || (curl "https://...index.php?controller..." ; touch /tmp/lastupdate)
     
  3. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,503
    Likes Received:
    2,179
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hi @nrcjea001,

    I'm glad to see you were able to find a cron job command that worked for what you needed. Thanks for sharing the outcome!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    nrcjea001 likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice