+91-98987 22266 | Blog

Mac OS X - Schedule cron jobs with crontab from Terminal

Running scripts on my Macbook Air was a challenge for me . I did some research and found that if you are on a Mac (or Linux), you can use crontab , which is a scheduling tool that will run jobs (scripts) at regular intervals.

crontab

Cronjob to crontab can be edited by editing the job list.We can specify the cronjob in the following format (first line): crontab

We can understand by using a simple example job. Lets create a simple cronjob to copy a particular file say "mysecretfile.txt" to a particular folder say "secretfolder" , and set this up to run once a day.
We'll set it to run as a cronjob by editing the job list (with the nano editor)

env EDITOR=nano crontab -e

Now enter the following and press CTRL + O and CTRL + X to save and exit.

0 12 * * * cp ~/mysource-folder/mysecretfile.txt ~/secretfolder/

This will execute the command every day at 12:00, which changes to the folder of the file and copies it.

Notice that if your computer is shut down or sleeping at the time, the script will not run until the next day at the specified time.

To see a list of your active crontab jobs, use the following command:

crontab -l

Disable email alerts

So after everything is set up, you might notice that the Terminal suddenly have started sending you e-mails.

You can disable this behaviour by inserting this line at the very top of your crontab file:

MAILTO=""

About TechnoIntellects

We are reputed Website Design, Development and Marketing agency with more than 16 years of experience. Read more

Keep in Touch

 

  contact (@) technointellects.com
  +91-9898 722266
  Ahmedabad,Gujarat, India

 

Get Map

TechnoIntellects WebSite Consultancy

Our Latest Blog

  • How to Disable Admin Tools in Joomla
    If you are accidentally locked out of his Joomla administrator by Admin Tools. Either by the strict security feature in Admin Tools that denies you access, even though he was a super user or you forgot the ‘Administrator secret URL parameter’. The error your will receive after several unsuccessful attempts will be : You are […]
  • Open Graph tags : Must-Have Social Meta Tags for Social Media Streams
    Facebook introduced Open Graph in 2010. It promotes integration between Facebook and other websites by allowing them to become rich “graph” objects with the same functionality as other Facebook objects. Open graph meta tags allow you to control what content shows up when a page is shared on Facebook. We’ve all seen posts like these […]
  • How to find RSS feed of a particular website?
    Not all websites/blogs have RSS feeds, but if they do, its easy to find the RSS Feed URL of those sites. If you want to do this through browser, press CTRL+U to view source, then CTRL+F to open find window and then just type in rss. RSS Feed url should appear immediately. It should look something like […]