Cron – How to run a cron job only once

cron

I have a job which runs forever the moment it starts.
So i want to start it only once after entering it into "crontab -e" file and saving it (or) whenever reboot happens.

How to achieve this?

Best Answer

If you want a command to run once at a later date, use the at command.

If you want a command to be run once at system boot, the correct solution is to use either:

  • system RC scripts (/etc/rc.local)
  • crontab with the @reboot special prefix (see manpage)

The latter is the only option for a non-root user.