1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How Wordfence runs its scan process even after page refresh?

Discussion in 'Programming' started by FutureKing, May 18, 2022.

  1. #1
    Normally I see that whenever we send request to PHP it processes the request and sends the response and process ends here. But Wordfence (Wordpress Plugin) performs scan continuously even if we refresh the webpage.

    I also want to build similar functionality to perform long running batch operations.

    Can anybody explain how Wordfence continuously runs its process even after page refresh?
     
    FutureKing, May 18, 2022 IP
  2. Einheijar

    Einheijar Well-Known Member

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    3
    Trophy Points:
    165
    #2
    You can always fork the process or spawn another one to run in the background.
    
    <?php exec('nohup /usr/bin/my-command > /dev/null 2>&1 &'); ?>
    
    Code (markup):
    This forks the sub-process into the background and writes all of the output into /dev/null. That way PHP continues executing the script as if there won't be any output it has to wait for.
     
    Einheijar, Jun 7, 2022 IP