Visualise craigslist, it has a page of Ads listed by most recent at top.
The Ad at the top of the list will drop down the list as new Ads are added.
If we give users the option to 'Bump Ad to top of listing every hour ‘for the next 3 hours’ (user can select how many hours)
The following should occur:
User1 Bump Ad starting now Wed 13:52 and selects 3 hours
We expect the Ad to be at the top of the list at these times:
14:52
15:52
16:52
If there is another user who also Bump Ad at a different time lets use 14:23
and also used 3 hours we expect user2 Ad to be at the top of the list at these times:
15:23
16:23
17:23
If the systemd timer is configured with the following:
[Timer]
OnActiveSec=1hr
OnUnitActiveSec=1hr
*(OnActiveSec=defines exactly one wakeup, after you issue “systemctl start foo.timer”. It is not repeated then, it’s a singular event)
*(OnUnitActiveSec=multiple, repetitive arguments, need to be combined with OnUnitActiveSec=)
If Timer is Activated at 12:00 it will create a time offset:
User1 by 52 mins
User2 by 23 mins
This would result in each users Ad being Posted early or late since they are both relative to the Timers’
first activation time which apparently is global in this scenario.
Ideally each User Bump Ad Time needs to be unique and have an individual timer as Activation reference for repeated hourly events so that the listing page
and the Posted time is exactly the time the user clicked the Bump Ad button, and be updated exactly 1 hour after that time for how ever many times later.
Considering if the web app has 5000 users with 5 Ads each, it obviously it is not practical to have 25,000 unique timers for each Ad.
So, can a single systemd timer be used and configured to allow each Ad to be Bumped with it’s own activation time and thus its repeated Bump time 1 hour after?
The unit executes a bash script:
#!/bin/bash
curl https://foo.com/bump-ad-by-cron
to which received is:
{“msg”:“successfully bump-ad by cron”}
Maybe this is not even possible with systemd, maybe a different approach needs to be made in PHP, not sure, but some ideas with systemd would be a start.
I could install cronie, not sure if cron is capable of the requirement.
Very much like this forum, if users had account function to repost their post to the top of the developer Discussion list starting now, every hour for 3 hours so other users see it at the top. My post time needs to be updated and unique and the same with another user if they also chose to have their post repost to the top, it would repost at their time of execution and repost exactly 1 hour after their initial time for 3 hours without delayed offsets.
bumpAd.sh
#!/bin/bash
curl https://foo.com/bump-ad-by-cron
===================================================
bumpAd.timer
[Unit]
Description=bumpAd
[Timer]
OnActiveSec=1hr
OnUnitActiveSec=1hr
[Install]
WantedBy=timers.target
===================================================
bumpAd.service
[Unit]
Description=bumpAd
[Service]
Type=oneshot
ExecStart=/usr/local/bin/bumpAd.sh
===================================================