Cronjob vs User编译脚本

I was thinking of programming a game in which battles are fight between players. I have done some research and read about two different ways of performing tasks when the player who's army is fighting is not online.

  1. use a cronjob to, lets say, every 5 minutes start a script to go through a wait list of tasks.
  2. make every user, when log in in or requesting any page start that same script.

Now my question is. What is the advantage/disadvantage of the first solution. And when I use the second solution, I will end up doing something like:

  1. Fetching the not jet performed tasks from the database by comparing "now" with a "last modified" date
  2. Change the "last modified" date to "now"
  3. Perform tasks

But do I not run the risk that a second user is opening the script in between step 1 and 2 and therefore performing the tasks twice?

Looking forward to your opinion.