Jump to content

cron jobs


Go to solution Solved by ginerjm,

Recommended Posts

Has anyone managed to create a cron job on their hosted domain from a running script?  I have a task that I do repeatedly and I would like to run a quick script that records the happening of that task and that then posts a new cron job to execute at a certain time to remind me via an email or text message.  That latter part I have written.  It is just the creating of the cron job that I am asking about.  Setting it up via my cpanel is just a pia and not something I am going to even consider.

Link to comment
https://forums.phpfreaks.com/topic/313674-cron-jobs/
Share on other sites

It's only hourly. That's nothing. Your alternative of dynamically creating cronjobs is... weird, like, it feels really weird. Cron isn't designed for one-off tasks like that. I'm not even sure why you (think you) need cron for this in the first place.

Link to comment
https://forums.phpfreaks.com/topic/313674-cron-jobs/#findComment-1589701
Share on other sites

You would be trading a negligible amount of resources to run your script unnecessarily for a lot less complexity. What's worth more to you: having to juggle cronjobs according to when you need them and when you don't, or always running some script that has a couple lines of logic that detect whether it needs to run?

Also consider that this "always schedule and stop running if unnecessary" is extremely common. It's so much easier and there is virtually no downside at all to having it in there. Trying to manage the cronjob is a micro-optimization that comes with a lot of complexity.

How long have you already spent trying to solve this problem? How much more time would it take to implement and troubleshoot it? It's just not worth your time.

Link to comment
https://forums.phpfreaks.com/topic/313674-cron-jobs/#findComment-1589703
Share on other sites

The cron job would be triggered by an app I already have.  When I run that quickie to post an activity my plan is to setup the one-time cron job to run at a specific time later on and that's it.  No juggling here and not very complex.  

I put in a little bit of time researching how to do this.  Then I decided to ask around.  

 

Link to comment
https://forums.phpfreaks.com/topic/313674-cron-jobs/#findComment-1589704
Share on other sites

The complexity here come from trying the add/remove your one-time cron jobs.  Cron isn't really designed for this type of usage so making it work this way would take a fair bit more effort on your part than doing the traditional way.  

Have you considered using at rather than cron?  It seems to fit your scenario better.

Link to comment
https://forums.phpfreaks.com/topic/313674-cron-jobs/#findComment-1589710
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.