Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Long-running background processes

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #182905
    Ferron
    Participant

    I’m using the Tumblr API PHP client and want to have it set up so that it grabs data from the API once every 24 hours and adds a record in a MySQL database. My question is, how would I go about doing a long-running process like that? I’ve looked into cron jobs but making it work through PHP seems kind of complicated. Is there any other alternative?

    #182957
    __
    Participant

    Cron jobs are way simple. There’s no need to start them through PHP (start them normally and have them call your php script).

    Is this your own machine? a VPS? shared host? Do you have access to the terminal? Here’s the man page.

    #182963
    Ferron
    Participant

    Thanks for the link! I’m on a shared host right now and do have SSH access, but ideally I wouldn’t want manually set a cron job through the terminal. I’m trying to write a basic analytics script that would just display the number of followers so (at least I think) I should do that without touching the terminal but possibly not.

    #182982
    __
    Participant

    but ideally I wouldn’t want manually set a cron job through the terminal.

    If it’s just because you’re worried about the terminal, you should know that it’s much easier. I’ve seen a few different examples of control panels that shared hosts provide for cron, and they were all horrible to use.* And that’s if your host even has one (check your host’s help pages).

    * …but trying to set it up from inside a php script is even worse. use your host’s CP (if available) or the terminal.

    #183373
    Ferron
    Participant

    Yeah, I am getting comfortable working in the terminal but the reason I don’t want to do it manually is because I kind of want this to scale, with multiple users and everything, and have it add a process automatically on registration (if I can). Manually adding it is fine for me but with multiple users registering I don’t think it would be viable.

    #183381
    __
    Participant

    Sure. Talk to your host.

    I kind of want this to scale, with multiple users and everything, and have it add a process automatically on registration (if I can)

    If I’m understanding you correctly, this is probably the wrong approach. It wouldn’t be efficient, and I really don’t think a shared host would be happy with you adding dozens of cron jobs.

    Start one job, and do {whatever you’re doing} for each user from that one script.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Back End’ is closed to new topics and replies.