Hi Padraig,

No idea on the direct answer to your question but just thought I might
suggest an alternative if such an action doesn't exist.

If this is in relation to the update manager and your are delivering
a SMF manifest then you can have the SMF instance's start and
stop method add and remove the cron jobs for you. 
This might be desirable since it if the entry gets deleted from a
cron job, it will automatically get added again when the service
gets restarted, and automatically removed if the service gets
disabled.

I pasted an example below in case it's of any interest to you.


Niall.



function add_cleanup_cronjob {
        # Call every 15 minutes, but 5 minutes after the smf snapshot
        # schedules which fall on the hour eg. (0, 15, 30, 45)
        SCHEDULE="5,20,35,50 * * * *"

        # adding a cron job is essentially just looking for an existing 
entry,
        # removing it, and appending a new one. Neato.
        crontab -l | grep -v "${CLEANUP_PROG}" \
            > /tmp/saved-crontab.$$

        echo "${SCHEDULE} ${CLEANUP_PROG}" \
            >> /tmp/saved-crontab.$$

        crontab /tmp/saved-crontab.$$
        check_failure $? "Unable to add cron job!"

        rm /tmp/saved-crontab.$$
        return 0
}

function remove_cleanup_cronjob {

        crontab -l | grep -v "${CLEANUP_PROG}" \
            > /tmp/saved-crontab.$$

        crontab /tmp/saved-crontab.$$
        check_failure $? "Unable to unschedule snapshots for $FMRI"

        rm /tmp/saved-crontab.$$

        # finally, check our status before we return
        STATE=$(svcprop -p restarter/state $FMRI)
        if [ "${STATE}" == "maintenance" ] ; then
            STATE=1
        else
            STATE=0
        fi
}



Padraig O'Briain wrote:
> I have a package which needs to add an entry to crontab on installation.
>
> Is there or will there be a crontab "action" which will allow me to do this?
>
> Padraig
> _______________________________________________
> pkg-discuss mailing list
> [email protected]
> http://mail.opensolaris.org/mailman/listinfo/pkg-discuss
>   

_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to