You should use cron, read the manpage for crond. With cron you can make a job done every hour.
As for the time variable, if you want to set a variable to the time you could use for example
where %F displays the date and %H is the hour.
markus@samsung:~$ time=$(date +%F_%H)
markus@samsung:~$ echo $time