PDA

View Full Version : SUSE - SLES 10 sp2 and SLES 11 sp 2 and sp 3 - CRON newbie



bowersgt
06-Nov-2013, 22:14
Hello all.

I have been thrown into the waters of the SLES environment...keeping head above water, but, I am in need of some assistance.

I'd like to get into the world of CRON on SLES, but am really struggling. I have no idea how to even start. I am familiar with
CRON a little bit from the Netware days.

Are there any good references that will step me through from the very beginning, I mean baby steps so I can start to get the hang of how to
use CRON and start automating some processes in SLES. I am trying to find examples that I can "see" the results to know if I am doing it right.
As I said, I am very new to the entire process.

At this point it appears I have SLES 10. sp2 OES2 and SLES 11 sp2 OES 11, and SLES 11 sp3 to manage.

Any help would be greatly appreciated!

Garry

KeN Etter
06-Nov-2013, 22:39
On Wed, 06 Nov 2013 21:24:02 GMT, bowersgt
<bowersgt@no-mx.forums.suse.com> wrote:

>
>Hello all.
>
>I have been thrown into the waters of the SLES environment...keeping
>head above water, but, I am in need of some assistance.
>
>I'd like to get into the world of CRON on SLES, but am really
>struggling. I have no idea how to even start. I am familiar with
>CRON a little bit from the Netware days.
>
>Are there any good references that will step me through from the very
>beginning, I mean baby steps so I can start to get the hang of how to
>use CRON and start automating some processes in SLES. I am trying to
>find examples that I can "see" the results to know if I am doing it
>right.
>As I said, I am very new to the entire process.
>
>At this point it appears I have SLES 10. sp2 OES2 and SLES 11 sp2 OES
>11, and SLES 11 sp3 to manage.
>
>Any help would be greatly appreciated!

Garry,

That's a bit open-ended, so I'm not sure exactly how to answer, but
here is an example of something I have done...might help.

I have a remote OES server that I backup nightly to my main office
using rsync. So I created a script that executes my rsync commands
and then sends me an email. I placed that script on the server and
then ran "crontab -e". Added a line that looks like this:
0 1 * * * /path/scriptname > /dev/null 2>&1
and then saved it by typing :wq

The script runs every day at 1 AM.
The "> /dev/null 2>&1" part of the line basically means execute the
script quietly.

Regards,
Ken

malcolmlewis
06-Nov-2013, 23:07
On Wed 06 Nov 2013 09:39:32 PM CST, KeN Etter wrote:

On Wed, 06 Nov 2013 21:24:02 GMT, bowersgt
<bowersgt@no-mx.forums.suse.com> wrote:

>
>Hello all.
>
>I have been thrown into the waters of the SLES environment...keeping
>head above water, but, I am in need of some assistance.
>
>I'd like to get into the world of CRON on SLES, but am really
>struggling. I have no idea how to even start. I am familiar with
>CRON a little bit from the Netware days.
>
>Are there any good references that will step me through from the very
>beginning, I mean baby steps so I can start to get the hang of how to
>use CRON and start automating some processes in SLES. I am trying to
>find examples that I can "see" the results to know if I am doing it
>right.
>As I said, I am very new to the entire process.
>
>At this point it appears I have SLES 10. sp2 OES2 and SLES 11 sp2 OES
>11, and SLES 11 sp3 to manage.
>
>Any help would be greatly appreciated!

Garry,

That's a bit open-ended, so I'm not sure exactly how to answer, but
here is an example of something I have done...might help.

I have a remote OES server that I backup nightly to my main office
using rsync. So I created a script that executes my rsync commands
and then sends me an email. I placed that script on the server and
then ran "crontab -e". Added a line that looks like this:
0 1 * * * /path/scriptname > /dev/null 2>&1
and then saved it by typing :wq

The script runs every day at 1 AM.
The "> /dev/null 2>&1" part of the line basically means execute the
script quietly.

Regards,
Ken


Hi
Further to Ken's comments, cron can be run by any user. For system jobs
(as opposed to creating a cron job for the root user), you can also
use the facilities in /etc/cron.hourly daily weekly and monthly to run
your own scripts, rather than entering via crontab.

You can configure the job to run at a specific daily time via
YaST->/etc/sysconfig editor.

The thing to remember is if you don't add a specific path in your
crontab, you need to ensure you use the full path to any scripts or
applications since cron has no environment.

The command;


crontab -l

will show the existing cron jobs for the user.

Perhaps a breakdown of the jobs your wanting to do on the different
systems may help as well. Since your using OES as well, there maybe
some specifics to watch out for since these are just the SLE forums.

--
Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
SLED 11 SP3 (x86_64) GNOME 2.28.0 Kernel 3.0.93-0.8-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below... Thanks!

mikewillis
06-Nov-2013, 23:09
The script runs every day at 1 AM.


I was taught not to schedule cron jobs that run on a Sunday for anytime between 1am and 2am inclusive. When we switch from GMT to BST the time goes from 00:59 to 02:00 and when we switch back the time goes from 01:59 to 01:00.

mikewillis
06-Nov-2013, 23:29
Are you new to Linux in general?

You could do worse than read the Wikipedia entry in cron
http://en.wikipedia.org/wiki/Cron
Which explains basics.

If you put a cronjob in a user's cron tab the output will get emailed to them so you can tell if it worked. E.g. If you put a job in root's crontab by running


$ crontab -e

As root the output of any jobs is emailed to root.

Malcolm mentioned the /etc/cron.hourly and similar directories already, I'll add that if you schedule jobs by putting files in there you can't guarantee the time they get run. There is a check done very 15 minutes to see if the hourly/daily/etc scripts ran. They're good for if you have machines which aren't always up and you want to ensure that something runs say once a day (/etc/cron.daily/) assuming the machine is up but aren't bothered exactly when in the day it runs.

jmozdzen
07-Nov-2013, 02:12
Hi Garry,

Hello all.

I have been thrown into the waters of the SLES environment...keeping head above water, but, I am in need of some assistance.

I'd like to get into the world of CRON on SLES, but am really struggling. I have no idea how to even start. I am familiar with
CRON a little bit from the Netware days.

Are there any good references that will step me through from the very beginning, I mean baby steps so I can start to get the hang of how to
use CRON and start automating some processes in SLES. I am trying to find examples that I can "see" the results to know if I am doing it right.
As I said, I am very new to the entire process.

At this point it appears I have SLES 10. sp2 OES2 and SLES 11 sp2 OES 11, and SLES 11 sp3 to manage.

Any help would be greatly appreciated!

Garry

as strange as it looks to me - somehow none of the others have mentioned the first and basic step: The online manual called "man"!

"man 8 cron" will tell you about th daemon that actually runs the jobs, "man 1 crontab" will tell you how to invoke the tool to manage the table(s) of cron jobs, and "man 8 crontab" will tell you about the table entries. ("man man" talks about how to use "man" and what those funny numbers are about, and always look out for "See Also" sections, i.e. "man 8 cron" references "man 1 crontab"...)

As the others have already pointed out, there is more to cron than is in the docs, but IMO that beyond the beginner's approach to cron.

Regards,
Jens

KeN Etter
08-Nov-2013, 20:16
On Wed, 06 Nov 2013 22:14:02 GMT, mikewillis
<mikewillis@no-mx.forums.suse.com> wrote:

>
>KeN Etter;17334 Wrote:
>>
>> The script runs every day at 1 AM.
>>
>
>I was taught not to schedule cron jobs that run on a Sunday for anytime
>between 1am and 2am inclusive. When we switch from GMT to BST the time
>goes from 00:59 to 02:00 and when we switch back the time goes from
>01:59 to 01:00.

Good point! I hadn't thought of that.

Thanks,
Ken