Assume I need to write a cron job to automate the installation of security update daily, which command I should use for better reliability?
You don't need a cron job to install security update.
unattended-upgrade do it for you, automatically.
From its description in pkg on Ubuntu 12.04
This package can download and install security upgrades automatically and unattended, taking care to only install packages from the configured APT source, and checking for dpkg prompts about configuration file changes.
you just need install it, then
then, choose "YES" and let it do its jobs.