From: "Harig, Mark" <maharig@idirect.net>
To: "René Haber" <rene.haber@gmx.de>
Cc: <cygwin@cygwin.com>
Subject: RE: cron: can't switch user context
Date: Wed, 10 Sep 2003 15:57:00 -0000 [thread overview]
Message-ID: <BADF3C947A1BD54FBA75C70C241B0B9E763574@ex02.co.idirect.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 1359 bytes --]
I cannot see the source of your problem from
the cygcheck listing. However, you are
running a Windows .NET server. I do not know
what effect that might have on cron.
Please run the attached cron_diagnose.sh
script. It is the latest version. I would
like for you to eliminate the possibility
that you ran an earlier version.
> -----Original Message-----
> From: René Haber [mailto:rene.haber@gmx.de]
> Sent: Sunday, September 07, 2003 1:06 PM
> To: cygwin@cygwin.com
> Subject: cron: can't switch user context
>
>
> Hello
>
> I've got Cygwin runnig on Windows 2003 and wanted to use the cron
> daemon. I installed it via
>
> cygrunsrv -I "CYGWIN crond" -p /usr/sbin/cron.exe -a -D
>
> as a NT-Service. Then I added a cronjob via "crontab -e" (I was logged
> in as Administrator)
>
> 5 * * * * echo "test" > test.txt
>
> after that, I started the cron-service and waited for the test-job to
> complete. But instead of doing the job cron complaind in the Syslog
> about
>
> Ereignisinformationen: /USR/SBIN/CRON : PID 228 : (CRON)
> error (can't switch user context).
>
> I checked my install via a shellscript (cron_diagnose.sh) I found in
> the Mailing-List Archiv, but it didn't find a problem.
>
> Is there a solution to this Problem or a work-around?
>
> Thanks.
>
> René Haber
>
[-- Attachment #2: cron_diagnose.sh --]
[-- Type: application/octet-stream, Size: 10766 bytes --]
#!/bin/bash
# ======================================================================
# $Source: $
# $Revision: $
# $Name: $
# $Date: $
# $State: $
# $Author: $
# ======================================================================
# ======================================================================
# This script checks for the various files, directories, and mount
# points needed by the cron daemon exist and have the proper settings,
# permissions, etc. This script is based primarily on the
# requirements listed in the text file /usr/doc/Cygwin/cron.README.
# ======================================================================
# ======================================================================
# Routine: check_program
# Check to see that a specified program ($1) is installed and accessible
# by this script. If it is not, then alert the user about which package
# ($2) should be installed to provide that program.
# ======================================================================
function check_program() {
if [ `type $1 > /dev/null 2>&1` ]; then
echo "The '$1' program is missing or not in your PATH."
echo "This program is included in the '$2' package."
echo "Please install this program and run this script again."
return 1
fi
return 0
} # === End of check_program() === #
# ======================================================================
# Routine: sanity_check
# Check for the set of programs that are used by this script.
# ======================================================================
function sanity_check() {
# Check for programs that this script uses.
check_program ls fileutils || return $?
check_program egrep grep || return $?
check_program id sh-utils || return $?
check_program cut textutils || return $?
check_program tr textutils || return $?
check_program mount cygwin || return $?
return 0
} # === End of sanity_check() === #
# ======================================================================
# Routine: check_passwd_and_group
# Check to see whether the user's password ID and group exist in the
# system /etc/passwd and /etc/group files, respectively.
# ======================================================================
function check_passwd_and_group() {
if [ "$(id -gn)" = mkpasswd ]; then
echo "It appears that you do not have an entry for your user ID"
echo "in /etc/passwd. If this check is incorrect, then re-run"
echo "this script with the '-f' command-line option."
echo
echo "Otherwise, use the 'mkpasswd' utility to generate an"
echo "entry for your User ID in the password file:"
echo " mkpasswd -l -u [User ID] >> /etc/passwd"
echo "or"
echo " mkpasswd -d -u [User ID] >> /etc/passwd"
return 1
fi
if [ "$(id -gn)" = mkgroup ]; then
echo "It appears that you do not have an entry for your group ID"
echo "in /etc/group. If this check is incorrect, then re-run"
echo "this script with the '-f' command-line option."
echo
echo "Otherwise, use the 'mkgroup' utility to generate an"
echo "entry for your group ID in the password file:"
echo " mkgroup -l -u > /etc/group"
echo "or"
echo " mkgroup -d -u > /etc/group"
return 1
fi
return 0
} # === End of check_passwd_and_group() === #
# ======================================================================
# Routine: check_dir
# Check to see that the specified directory ($1) exists.
# ======================================================================
function check_dir() {
if [ ! -d $1 ]; then
echo "Your computer does not appear to have a $1 directory."
echo "Please investigate this problem, and run this script again."
return 1
fi
if [ `ls -ld $1 | egrep -q '^dr[-w]x.*'` ]; then
echo "The permissions on the directory $1 are not correct."
echo "Please run 'chmod u+rx $1', and run this script again."
return 1
fi
return 0
} # === End of check_dir() === #
# ======================================================================
# Routine: check_dir_perms
# Check to see that the specified directory ($1) exists and has the
# required permissions, as described in /usr/doc/Cygwin/cron.README.
# ======================================================================
function check_dir_perms() {
check_dir $1 || return $?
if [ `ls -ld $1 | egrep -q 'drwxrwxrxt'` ]; then
echo "The permissions on the directory $1 are not correct."
echo "Please run 'chmod 1777 $1', and run this script again."
return 1
fi
return 0
} # === End of check_dir_perms() === #
# ======================================================================
# Routine: check_var_run
# Check to see that SYSTEM or the Administrators group has write
# permission in the directory /var/run. This permission is needed
# so that the cron.pid file can be created by the cron service.
# ======================================================================
function check_var_run() {
# We check from least- to most-restrictive permission.
# If 'everyone'/'other' does not have write permission, then
# check to see whether group permissions are sufficient.
if [ $(ls -dl /var/run | cut -b9) != w ]; then
# If 'Administrators' has group access to /var/run, but does not have
# write permission, then check to see whether user permissions are
# sufficient.
if [ $(ls -dl /var/run | tr -s " " | cut -f4 -d " ") = Administ ] && \
[ $(ls -dl /var/run | cut -b6) != w ]; then
# If SYSTEM is the owner of /var/run and does not have write
# permission, then notify the user.
if [ $(ls -dln /var/run | tr -s " " | cut -f4 -d " ") -eq 18 ]; then
if [ $(ls -dl /var/run | cut -b3) != w ]; then
echo "The directory /var/run cannot be written to by its owner."
echo "Please check/change the permissions of /var/run and run"
echo "this script again. For example:"
echo " chmod u+w /var/run"
return 1
fi
else
echo "The SYSTEM user or Administrators group needs to have"
echo "write permission in the directory /var/run. Please"
echo "check/change the user and/or group ownership and"
echo "permissions and run this script again."
return 1
fi
fi
fi
return 0
} # === End of check_var_run() === #
# ======================================================================
# Routine: check_sys_mount
# Check to see that the SYSTEM account has access to the specified
# directory.
# ======================================================================
function check_sys_mount() {
local mnt_point=$1
local dos_dir=$2
# Check to see that SYSTEM can access /usr/bin:
if ! mount | grep -qe ".\+ on $mnt_point .\+system.\+"; then
echo "The SYSTEM user cannot access the mount point ${mnt_point}."
echo "Please run the following command to add a system mount point:"
echo ' mount -f -s -b "[DOS path to Cygwin]'$dos_dir\" \"$mnt_point\"
echo "where [DOS path to Cygwin] is something like c:/cygwin."
echo
echo "For more information, run 'mount -m' and 'mount -h'"
echo
echo "After adding this mount point, please re-run this script."
return 1
fi
return 0
} # === End of check_sys_mount() === #
# ======================================================================
# Routine: check_cron_table
# Check for the existence of a crontab for the user, and check its
# permissions and ownership.
# ======================================================================
function check_cron_table() {
local user_id=$(id -un)
local cron_table=/var/cron/tabs/$user_id
if [ ! -f $cron_table ]; then
echo "Your computer does not appear to have a crontab for $user_id."
echo "Please generate a crontab for $user_id using 'crontab -e',"
echo "and run this script again."
return 1
fi
if [ `ls -l $cron_table|egrep -q 'rw-r-----'` ]; then
echo "The permissions of your crontab file are set to:"
ls -l $cron_table
echo "They need to be set to read/write for $user_id and"
echo "to read-only for group. You can set these with"
echo " chmod 640 $cron_table"
echo "Please check your crontab's permissions, and run"
echo "this script again."
return 1
fi
if [ `ls -l $cron_table|cut -d" " -f8|egrep -q SYSTEM` ]; then
echo "The group membership of your crontab file should be SYSTEM,"
echo "as documented in the file /usr/doc/Cygwin/cron.README."
echo "You can change this setting with:"
echo " chgrp SYSTEM $cron_table"
echo "Please check your crontab's group membership, and"
echo "run this script again."
return 1
fi
if [ `ls -ln $cron_table|cut -d" " -f8|egrep -q 18` ]; then
echo "The value of SYSTEM in your /etc/group file needs to"
echo "be the reserved number '18', as documented in"
echo "/usr/doc/Cygwin/cron.README. Please investigate this"
echo "and run this script again."
return 1
fi
echo "This script did not find any errors in your crontab setup."
echo "If you are still unable to get cron to work, then try"
echo "shutting down the cron service, uninstalling it,"
echo "reinstalling it, and restarting it."
echo
echo "The following commands will do that:"
echo " $ cygrunsrv --stop cron"
echo " $ cygrunsrv --remove cron"
echo " $ cygrunsrv --install cron -p /usr/sbin/cron -a -D"
echo " $ cygrunsrv --start cron"
echo
if [ -f /var/run/cron.pid ]; then
echo "If the cron service does not start, try deleting the file"
echo "/var/run/cron.pid and then repeating the commands above."
echo
fi
echo "If none of this fixes the problem, then report your problem"
echo "to cygwin@cygwin.com. Please include a copy of your crontab,"
echo "('crontab -l') and the output of 'cygcheck -srv > cygcheck.txt'."
echo
echo "PLEASE include the generated files 'cygcheck.txt' *as an attachment*,"
echo "and NOT in the body of the mail message."
return 0
} # === End of check_cron_table() === #
function main() {
echo "cron_diagnose.sh 1.0"
echo
sanity_check || return 1
if [ "$1" != '-f' ]; then # Allow the user to skip the password check.
check_passwd_and_group || return 1
fi
check_dir /etc/cron.d || return 1
check_dir /var || return 1
check_dir_perms /var/cron || return 1
check_dir_perms /var/cron/tabs || return 1
check_var_run || return 1
check_sys_mount /usr/bin /bin || return 1
check_sys_mount /usr/lib /lib || return 1
check_sys_mount / / || return 1
check_cron_table || return 1
return 0
} # === End of main() === #
# Entry point:
main $@
exit $?
# === End of $RCSfile$ === #
[-- Attachment #3: Type: text/plain, Size: 218 bytes --]
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
next reply other threads:[~2003-09-10 15:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-10 15:57 Harig, Mark [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-04-27 10:37 Cron " Peter Pfannenschmid
2021-04-28 0:14 ` Brian Inglis
2021-04-28 4:32 ` Andrey Repin
[not found] <BADF3C947A1BD54FBA75C70C241B0B9E763574@ex02.co.idirect.net >
2003-09-10 16:12 ` cron: " Larry Hall
2003-09-14 21:22 ` René Haber
2003-09-07 17:06 René Haber
2003-09-07 18:08 ` Igor Pechtchanski
2003-09-08 17:30 ` René Haber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BADF3C947A1BD54FBA75C70C241B0B9E763574@ex02.co.idirect.net \
--to=maharig@idirect.net \
--cc=cygwin@cygwin.com \
--cc=rene.haber@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).