X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:mime-version:date:message-id:subject:to :content-type; q=dns; s=default; b=HH0YSUuobk4L7q/g8P4bVj3kOVUNK d7dN3AV0efaHJMa4sKVGNx/HKyExGtARqQ+P25WSq+VxWVOwCfzgBFxfOgDOnRGt Alk2tG8KDngDHnFSVsXRgYmc8H9MjWNvYProefpFyelcy0gyY6LmAw8nAPbACrEo ui3esPC8e9TefU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:mime-version:date:message-id:subject:to :content-type; s=default; bh=oQ2fbTPkAREawYtgIrQR5Ip2zNA=; b=IGn F0UNrQq2cD3TUQHHFOfznMuCIMgYbu1VitwhpyuurB1a88TBSXgCEilQ1lf8F7DB AbL753lC+RNjrd1hqSIh3r/YqtIsuIQ7heE8MZc7NBR9+VeKh+TIVTENnzII0kf7 BWZdIhdNfdlnFwyXFU7CPPZ7s8Ex9ZdFwXLzx1hU= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=PID, 608, pwd, cronbug X-HELO: mail-lb0-f179.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:thread-index:date:message-id :subject:to:content-type; bh=oijV6Gh2wLvbnnlyzCeb0ZHf1ZGZi2j3OELLqOcTFMg=; b=l3PdNy1BgJZ0FBgBcX46KipV7lVpn5uvha5YftF93BBsPc6PjEvdDreZdqFcceIxYb kyE1GQXeOU2O3fhAwt1yfhnhMgGAbrppB9Vi9tBGKF8tucFVGcEpuJ4xXlvXhKh9FR5p sZsCWRUX/wQ1Q2vanF9nC9rzv2lTdz6+bzV1PgiFcaHisB0RUzxs8EYD5rk9ChbGad1S L6hhWuYz+sEd3J5708VGuOcFuaBldGC/UR2u8rPvY5VslAcrjQ1aMCbdpPpD7oiauN6i reHlBXhw3kCvWINS8ClVPn0nDkobiAOQTZJTviYCQ8+z3mh3B9glo7GCvKNaHDOcYV3M oXGA== X-Gm-Message-State: ALoCoQn2Tg12Im5nnlsc59/xfcAogG8deco1FdkSxHw0aanrJwr3rJ7ZaMaJSPpQPY/NDN/pSkqtoFtqtTRig9NNmQlHydg9QzCThBpx+HbWsfxFbLhtfg0= X-Received: by 10.112.13.193 with SMTP id j1mr19127294lbc.24.1452699176360; Wed, 13 Jan 2016 07:32:56 -0800 (PST) From: Chuck Roberts MIME-Version: 1.0 Date: Wed, 13 Jan 2016 10:31:48 -0500 Message-ID: <7a01c4d60423fa39806d8e6746c2954b@mail.gmail.com> Subject: RE: cron bug To: cygwin Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes > Hello, > > I have set up cron as below on a fresh Windows 10 with a fresh, > minimal 64-bit Cygwin installation. Cronjobs are not executed and cronevents says /usr/sbin/cron: > PID 608: (CRON) error (can't switch user context). The output of > cronbug is attached. > > When I run the service not under my own user but as an administrator, > the result and error is the same. First I try not to make any assumptions about what the user knows about cron. So here are some tips. - In general, do not edit the system crontab files, instead edit your user crontab files with 'crontab -e' where '-e' means edit. You will need an environment variable to setup an editor like this: 'export EDITOR=nedit'. You can put the whole path to nedit in there if need be. So, what is the exact command you are using to edit the crontab files? - When the cron job runs it runs in it's own shell, with no environment variables at all, i.e. no PATH or anything. To set environment variables add these entries to the crontab file: PATH=/usr/bin:/sbin:/whatever MAIL=youruser (sends email to this account) Each time cron runs and produces output, an email is sent to the account in the MAIL variable. - Next, the command must include the full path to the command like this: 1 18 29 1 * /home/comp/perl/me/gocron If gocron is a bash script which calls a Perl program, I always pass the working directory to my Perl program inside the 'gocron' bash script. I think I had trouble getting the current directory inside my Perl script with $t=`pwd`;. It would work during testing outside of cron, but when it was run by cron, pwd didn't work. I also test my bash scripts with the 'at' command, which works very much like cron, but with less typing. The at format is: at -f FILETORUN TIMESPEC Example: at -f /path/to/file/gocron now (run now) Example: at -f /path/to/file/gocron + 1 minute (run 1 minute from now) Example: at -f /path/to/file/gocron 2:05pm (runs at 2:05pm based on the server time) This runs my gocron bash script after 1 minute passes. See the man page for 'at' for more info on the TIMESPEC format. Chuck -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple