Solved

Setting task in crontab to be execuded everyday

Posted on 2015-02-08
2
108 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 38

Expert Comment

by:Gerwin Jansen, EE MVE
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem logging tar errors 11 68
mobaxterm not able to change directory 28 278
aix unix tar error 3 81
Replacing multiple embedded commas in a CSV file with sed 10 23
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
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.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

740 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