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?
|
feedback
|
|
If you want a command to run once at a later date, use the If you want a command to be run once at system boot, the correct solution is to use either:
The latter is the only option for a non-root user. | |||||||||||||
feedback
|
|
You could use at(1) to run a job at some point in the future. However, if you want to run something on boot and it'll stay running by itself, maybe you want an entry in /etc/init.d/ for it? That would let you start it on boot. | |||||||||||||||
feedback
|
|
Have a look at the at command | |||||||||
feedback
|
|
A job that runs only once and runs forever till you tell it to die is called a "daemon". They are normally started via init scripts in /etc/init.d/. If your job ends at some point and can be considered a one-off kind of job, then you may want to look at the at command. For instance if I wanted to run the find command at 10PM tonight and only this once I would do:
| |||
|
feedback
|