0

Use Case: User can post anytime on Facebook even after 6 months. In the backend, I'll be storing the posts with user content and will be running a cron job to make post through access token. This way I can post on user/page/group withoout any issues. But it seems cron part is not very clear to me. Consider following scenario:

User A wants to schedule his post at 7 pm on Thursday. User B wants to schedule his post at 7:05 pm on Thursday. User C wants to schedule his post at 7:03 pm on Thursday. User D wants to schedule his post at 8 pm on Thursday. User E wants to schedule his post at 7:10 pm on Thursday. and many more.....

Now, How can I put a cron job to meet all these requirements? My point is we can run cron job after every 5 mins or something like that..may be on hourly basis but this way I may skip some posts. How can I make sure I don't miss any of the post. Also, I can run a job in background continuously but that will put extra load on the server.

I found following thread but still not able to correlate my problem to this. Also, I got this solution as a part of my previous question which can be found here.

Any suggestions are welcome.

Community
  • 1
  • 1
dark_shadow
  • 3,503
  • 11
  • 56
  • 81

1 Answers1

1

You can run a Cron Job every minute. If you just check for posts to schedule, it will not really be a big problem for the server.

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • But won't it add a lot of load on the server and the db. We are running it every minute 24x7 everytime querying the db for any post to schedule. Is there any smart way by which I can make this task more efficient ? – dark_shadow Aug 25 '15 at 04:16
  • 1
    a simple query without any complicated stuff takes some milliseconds, that´s not really a problem for any server. – andyrandy Aug 25 '15 at 07:11