Automatically rebuilding site on production server

I have a basic LAMP stack (Ubuntu) running on Linode. The Hugo content directory is located in a Dropbox folder that syncs to the server (outside of my web directory). Hugo can then build the site with the publish directory pointing to my web directory.

So my (likely stupid) question: Is there a preferred way to have Hugo rebuild the site automatically upon detecting new files in the Dropbox folder? My goal is to write an article anywhere that supports Dropbox (Desktop, Phone, iPad, etc) and to have the site update once I save.

I suppose the “watch” mode is designed for this, but another thread hinted that this might be a bad idea. If “watch” is best way, how would I go about just having that run in the background? I thought about using @reboot command in crontab. If not, what would you recommend?

Thanks for any insight.

If you have a LAMP stack, I would stick with the Apache server (A in LAMP) – that rules out the watch mode. Watch mode would work in your case, but consumes CPU, power etc …

In your case I would go the simple path and set up a cron job to rebuild the site every n minutes. If you need more speedy updates (do you? even a cron job that builds every minute would be cheap in the Hugo world), I would go with GitHub or DropBox web hooks (have a web accessible service on your service that triggers a rebuild).

This script could even check for changes since last build ot save some resources.

Awesome. Thanks for the help! Your suggestions make sense. I will probably just go with the cron idea.

Yea, and the cron build every n minutes would also cover the “publishing of future posts” use case.