Solved

Setting task in crontab to be execuded everyday

Posted on 2015-02-08
2
103 Views
Last Modified: 2015-03-05
I need to get executed myscript.ksh everyday at 7:05 a.m.

How can i say that in my crontab??
0
Comment
Question by:celtician
2 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 40597116
User crontab:

5 7 * * * /path/to/myscript.ksh >/path/to/myscript.log 2>/path/to/myscript.err

System crontab (/etc/crontab):

5 7 * * * username  /path/to/myscript.ksh >/path/to/myscript.log 2>/path/to/myscript.err

The first field defines the minute (0-59 or *) , the second defines the hour (0-23 or *).
The asterisks mean "every possible value", where the third field defines the day of month (1-31 or *), the next one defines the month (1-12 or * ) and the fifth one defines the day of week (0-6 or 1-7 or *; 0 or 7 mean "Sunday").
The sixth field is in the system crontab the name of the user under whose credentials the script should run, in the user crontab it's the name of the command/script (which is the seventh field in the system crontab).

Instead of ">/path/to/myscript.log 2>/myscript.err" you can discard all possible output with ">/dev/null 2>&1".
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40597283
If you run into errors while cron is executing your myscript.ksh - check the script if it needs any path settings. When you run myscript.ksh interactively in your environment it will probably run just fine. You may need to set a path in your script or put every command in there with a full path so it runs from cron as well.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now