I'm trying to create a cron that will run one time at a specific time.

For simplicity, how can I create a cron that will run at 11:57PM and print "Hello" to the screen then delete itself? (Cent OS 5)

link|improve this question
feedback

2 Answers

up vote 4 down vote accepted

If you need it to run just once, cron is not your tool.

at (1)               - queue, examine or delete jobs for later execution

E.g.:

# at 12:57PM
warning: commands will be executed using /bin/sh
at> echo hello
at> <EOT>
job 2 at Mon Jan  2 12:57:00 2012

(Press ctrl+d when done entering commands)

Scheduling relatively to now

fbh@pinky:~$ at now + 5 min
warning: commands will be executed using /bin/sh
at> echo moo
at> <EOT>
job 5 at Mon Jan  2 06:05:00 2012

And as always, read much more on how to use this tool in the man page for it.

link|improve this answer
feedback

If you use at, the output of the command will be emailed to you. To output text to the current terminal do the following:

echo "echo 'hello' > `tty`" | at 11:57PM
echo "echo 'hello' > `tty`" | at now + 5 minutes

Note that when you use now + x minutes, the execution time will be rounded to the previous minute.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.