[prev in list] [next in list] [prev in thread] [next in thread] 

List:       opensolaris-discuss
Subject:    Re: [osol-discuss] Working with Cron under Solaris 10
From:       Brian Ruthven - Solaris Network Sustaining - Oracle UK
Date:       2011-01-20 15:12:58
Message-ID: 4D3850FA.9050100 () oracle ! com
[Download RAW message or body]



Ron Halstead wrote:
> pgrep -fl cron
>   508 /usr/sbin/cron
>
> sudo kill 508 # or sudo pkill cron
>   

As a general rule for SMF-controlled processes, the first command only 
works if the service is configured to ignore signals (which cron is). 
Specifically, kill will succeed in sending the signal, but this may put 
the service into maintenance mode if the "startd/ignore_error" property 
does not specify "signal".

The second command is dangerous in the presence of zones when run from 
the global zone, as it will send the -TERM signal to all crons in all 
zones. Probably not what you wanted.

Actually, the first command can also be dangerous in the presence of 
zones. How do you know which zone each cron is running in? ps -Z will 
tell you, but it's an additional step, and more to get wrong.

The correct (and quite easy) way to restart a service in the current 
zone only is:
    svcadm restart svc:/system/cron:default
    (or "svcadm restart cron" will suffice)

This will also take care of running the stop method to clean up any 
state, etc. However, as others have noted, there is no need for this on 
Solaris as long as you use the crontab(1M) interface and are not 
hand-editing the underlying /var/spool/cron/crontabs/* files directly 
(which I would recommend against as it bypasses the initial 
syntax/format checking that crontab(1m) performs).

Personally, I maintain a separate file with my crontab entries. Then I 
can edit it and "upload" the new version to cron using "crontab 
crontabfile". This then also helps protect me from the somewhat 
irritating "crontab -r" instead of "crontab -e". Oh how many times I've 
removed my crontab instead of editing it by slipping off the 'e' key and 
hitting return before my brain caught up.


Regards,
Brian

-- 
Brian Ruthven
Solaris Network RPE (Sustaining)
Oracle UK

_______________________________________________
opensolaris-discuss mailing list
opensolaris-discuss@opensolaris.org
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic