Solved

Setting task in crontab to be execuded everyday

Posted on 2015-02-08
2
105 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using Grep to Find a file 8 85
Choosing the right language for new project 8 61
What are recommended OS for exim mail server? 10 101
Access_log 17 100
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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.

911 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

25 Experts available now in Live!

Get 1:1 Help Now