My school has an apache/mysql server that we make and host websites from as projects. I am doing an ebay type site where people bid on a product until time runs out. Problem is I don't know how to trigger that the product should be delisted and the buyer and seller notified that the auction is over. mysql trigger updates only work when a mysql action like select, insert delete, etc are triggered, I'm not sure about php (If my website would get more traffic then simply me editing and maintaining it, I would simply run a php script every time the index page is accessed. But I might do that anyway.) and honestly, I think this might be impossible without higher access privileges. I would like to note I have access to the GCC compiler, and can confirm I can compile program (just not installing programs for obvious reasons).

I'm currently skimming through: to see if this is possible in my position.

Dani AI

Generated

— several practical options exist without admin rights; each has tradeoffs. ’s cron-based approach is the simplest and most reliable when a per-user crontab is permitted. ’s inotify idea is useful for file-driven triggers but is not a natural fit for time-based auction expiry unless some external process touches a file at the expiry moment.

If cron is available, implement a small maintenance script that runs regularly and does three things in a transaction: find auctions with end_time <= NOW() and status = 'open'; determine the highest bid for each auction; atomically mark the auction closed and create notifications/records for buyer and seller. Example transaction skeleton:

START TRANSACTION;
-- lock/identify auctions to close
-- find top bid per auction
-- UPDATE auctions SET status='closed', winner_id = ? WHERE id = ? AND status = 'open';
-- INSERT notification rows for winner and seller
COMMIT;

If no cron access exists, two practical fallbacks are available. The “on‑hit” method runs the same maintenance script when pages are loaded, but only if a recent run timestamp indicates the job is overdue; use a DB lock or an atomic flag row to prevent concurrent runs and avoid race conditions. A long‑running user process (compiled C/PHP worker) is possible by detaching it with a session manager, but shared hosts often prohibit persistent user daemons and they won’t survive reboots.

A few hard rules regardless of method: make the closure operation idempotent (conditional UPDATE that only closes status='open' rows), use transactions or row locks when selecting winners, give the DB user minimal privileges, and queue email sending rather than sending synchronously. If MySQL events are enabled on the server, the built-in event scheduler can also run similar logic — but that depends on server configuration.

Recommended Answers

All 4 Replies

You can write a program or script that uses inotify to inform you when a file is accessed, opened, modified, created, deleted, etc. See the inotify man page for more information.

OK. I can use this to trigger sql queries at certain times?

I wanted to work on the server that we make and host website.So i need help ????

If you have an account on the server, you can use cronjobs which regularly trigger actions. I recommend that you set up a PHP script which does whatever bookkeeping you need, and that you call it either directly with

php <myscript.php> 

or via the apache server using

wget http://<myserver>/<myscript.php>

If you can do that from the command line, you can put the command in your crontab which you can edit with

crontab -e

from the command line.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.