read

Recently came across a command in Unix like systems called

at

This command executes any command given at the specified date time. Here is an example

at takes time and data as parameter so if you want to run a task at midnight on Dec 25th you can run

at midnight Dec 25

followed by the command you want to run and end it by pressing Control-D.

If you specify just time it will try to execute that command at that time today. If the time is past the current time today then it will execute it tomorrow at that time. For example if you run a command at 3pm and it is 1pm currently then the command will run 2 hours later but if it is 5pm then it will run at 3pm next day.

Alternately you can pass a file and write commands to that file that you want to run and pass that. Benefit of doing this is that you can keep appending or changing the task file and it will run all the commands in that file.

The command runs the task only once so to keep running it periodically you need to run the command again or you can run it as the very last task in the task file and the command will then execute at the time specified the next day.

This command might be useful to some who do not want to setup cron jobs on the server. If you have multiple servers, it might be helpful to have your web application run this command on the machine it runs and it will give you the functionality of scheduled tasks without the hassle of synchronizing the crontab file across all servers.

Blog Logo

Ankur Patel


Published


If you like my blog you might also enjoy reading my book called Hands-on Full-stack Swift Development

Purchase a paperback copy or eBook from Amazon, Barnes and Noble or other online retailers.

Image

Ankur અંકુર Patel

Full Stack Ruby on Rails, Frontend Web and native iOS App Developer | Author of "Hands-on Full-Stack Development with Swift" amazon.com/author/ankurpatel

Back to Overview