I want to protect a sub domain where the user is only given access for 1 day. Is it possible to set up a cron job that will automatically update a .htpasswd file with a new password daily?
You should probably use an application that was meant to do this, rather than hacking something together with cron. But, if you must make it hackalicious...
You'll have to run htpasswd in "batch mode". From the htpasswd man page:
Something like this should work:
Normally I would only answer: Yes it is possible.
But you can even integrate a database where the user and password is stored. For example