Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Setting task in crontab to be execuded everyday

Posted on 2015-02-08
2
Medium Priority
?
116 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 2000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month20 days, 15 hours left to enroll

810 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