Re: cron

Jerry K <[email protected]> Tue, 28 Feb 2012 17:08:14 -0600
Newsgroups gmane.comp.macosx.admin
Message-ID <[email protected]>
So did the cron issue ever get resolved, or is the issue still being worked through?

If it did get resolved, what was the final solution?

Thanks for the follow up.

On 02/27/12 10:55 AM, János Löbb wrote:
> Hi Larry,
> 
> I thought I used full paths.  In the crontab entry surely I do it:
> bml0041:shell_script janos$ crontab -l
> 10	*	*	*	*	/Volumes/Data/PROJECTS/Sysmon/shell_script/del_from_sequoia.ksh > /Volumes/Data/PROJECTS/Sysmon/shell_script/del.txt
> 
> and I also redirect its output, to the del.txt file.
> 
> Inside the script I also use absolute paths:
> bml0041:shell_script janos$ cat del_from_sequoia.ksh 
> #!/bin/bash
> #
> scp [email protected]:/prod2/ase15/sysmon/sysmonlogs/*.log /Volumes/Data/PROJECTS/Sysmon/sysmsa/
> 
> ssh [email protected] "find /prod2/ase15/sysmon/sysmonlogs -name '*.log' | xargs rm "
> 
> Checking my mail on my machine I see cron demaon messages with content like:
> 
> <nyissz>
> Subject: Cron <janos@bml0041> /Volumes/Data/PROJECTS/Sysmon/shell_script/del_from_sequoia.ksh > /Volumes/Data/PROJECTS/Sysmon/shell_script/del.txt
> X-Cron-Env: <SHELL=/bin/sh>
> X-Cron-Env: <PATH=/usr/bin:/bin>
> X-Cron-Env: <LOGNAME=janos>
> X-Cron-Env: <USER=janos>
> X-Cron-Env: <HOME=/Users/janos>
> Date: Mon, 27 Feb 2012 05:10:02 -0500 (EST)
> 
> Permission denied, please try again.
> Permission denied, please try again.
> Permission denied (publickey,password,keyboard-interactive).
> Permission denied, please try again.
> Permission denied, please try again.
> Permission denied (publickey,password,keyboard-interactive).
> <nyassz>
> 
> As I know cron inherits my rights when executes a task assigned to my name.  I own those directories where cron has to write on behalf of me.  Now I made the shell_script and the sysmsa directories writable to anyone, that is chmod 777.  I will see in a half hour if it works now or not.
> 
> I do not understand the :
> Permission denied (publickey,password,keyboard-interactive).
> 
> [email protected] is set up - of course it is faked here :-) - with a certificate that I do not have to type a password when I log into the AIX machine.
> 
> So, looks like cron tries to do its job, but either it was unable to write where I could, or it does not get the right credentials when it tries to connect to the seq machine as syb.
> 
> Thanks ahead,
> 
> János
> 
> 
> On Feb 27, 2012, at 11:10 AM, Lawrence Sica wrote:
> 
>> Well you are not capturing stderr in your file.  You won't see any errors as a result.  Try running it to capture stdout and stderr.  Also I recommend using full paths to commands in a cron run script since the environment is not the same as when you run it from the command line.
>>
>> --Larry
>>
>>
>> On Feb 27, 2012, at 10:56 AM, János Löbb <[email protected]> wrote:
>>
>>> Hi Jerry,
>>>
>>> When I execute the script on the command prompt, it works like charm:
>>>
>>> <nyissz>
>>> bml0041:shell_script janos$ ./del_from_sequoia.ksh 
>>> 2012_02_23_15.log                                                                                                         100%   75KB  74.9KB/s   00:00    
>>> 2012_02_23_16.log                                                                                                         100%   75KB  75.5KB/s   00:00    
>>> 2012_02_23_17.log                                                                                                         100%   76KB  75.7KB/s   00:00    
>>> 2012_02_23_18.log                                                                                                         100%   74KB  74.5KB/s   00:00    
>>> 2012_02_23_19.log                                                                                                         100%   75KB  74.7KB/s   00:00    
>>> 2012_02_23_20.log                                                                                                         100%   75KB  74.7KB/s   00:00    
>>> 2012_02_23_21.log                                                                                                         100%   73KB  73.2KB/s   00:00    
>>> 2012_02_23_22.log                                                                                                         100%   74KB  73.8KB/s   00:00    
>>> 2012_02_23_23.log                                                                                                         100%   73KB  73.2KB/s   00:00    
>>> 2012_02_24_00.log                                                                                                         100%   77KB  77.1KB/s   00:00    
>>> 2012_02_24_01.log                                                                                                         100%   76KB  75.6KB/s   00:00    
>>> 2012_02_24_02.log                                                                                                         100%   75KB  74.6KB/s   00:00    
>>> 2012_02_24_03.log                                                                                                         100%   75KB  74.6KB/s   00:00    
>>> 2012_02_24_04.log                                                                                                         100%   76KB  75.9KB/s   00:00    
>>> 2012_02_24_05.log                                                                                                         100%   75KB  75.0KB/s   00:00    
>>> 2012_02_24_06.log                                                                                                         100%   75KB  75.1KB/s   00:00    
>>> 2012_02_24_07.log                                                                                                         100%   76KB  75.6KB/s   00:00    
>>> 2012_02_24_08.log                                                                                                         100%   75KB  75.5KB/s   00:00    
>>> 2012_02_24_09.log                                                                                                         100%   75KB  75.4KB/s   00:00    
>>> 2012_02_24_10.log                                                                                                         100%   75KB  74.9KB/s   00:00    
>>> 2012_02_24_11.log                                                                                                         100%   75KB  75.3KB/s   00:00    
>>> 2012_02_24_12.log                                                                                                         100%   75KB  75.1KB/s   00:00    
>>> 2012_02_24_13.log                                                                                                         100%   75KB  75.0KB/s   00:00    
>>> 2012_02_24_14.log                                                                                                         100%   75KB  75.3KB/s   00:00    
>>> 2012_02_24_15.log                                                                                                         100%   75KB  75.5KB/s   00:00    
>>> 2012_02_24_16.log                                                                                                         100%   76KB  75.9KB/s   00:00    
>>> 2012_02_24_17.log                                                                                                         100%   75KB  74.9KB/s   00:00    
>>> 2012_02_24_18.log                                                                                                         100%   75KB  75.2KB/s   00:00    
>>> 2012_02_24_19.log                                                                                                         100%   74KB  74.2KB/s   00:00    
>>> 2012_02_24_20.log                                                                                                         100%   75KB  74.6KB/s   00:00    
>>> 2012_02_24_21.log                                                                                                         100%   74KB  74.5KB/s   00:00    
>>> 2012_02_24_22.log                                                                                                         100%   74KB  74.3KB/s   00:00    
>>> 2012_02_24_23.log                                                                                                         100%   73KB  73.2KB/s   00:00    
>>> 2012_02_25_00.log                                                                                                         100%   77KB  77.2KB/s   00:00    
>>> 2012_02_25_01.log                                                                                                         100%   75KB  75.0KB/s   00:00    
>>> 2012_02_25_02.log                                                                                                         100%   75KB  75.5KB/s   00:00    
>>> 2012_02_25_03.log                                                                                                         100%   75KB  74.9KB/s   00:00    
>>> 2012_02_25_04.log                                                                                                         100%   76KB  75.6KB/s   00:00    
>>> 2012_02_25_05.log                                                                                                         100%   75KB  75.5KB/s   00:01    
>>> 2012_02_25_06.log                                                                                                         100%   75KB  75.3KB/s   00:00    
>>> 2012_02_25_07.log                                                                                                         100%   74KB  74.2KB/s   00:00    
>>> 2012_02_25_08.log                                                                                                         100%   75KB  74.9KB/s   00:00    
>>> 2012_02_25_09.log                                                                                                         100%   74KB  74.5KB/s   00:00    
>>> 2012_02_25_10.log                                                                                                         100%   74KB  74.5KB/s   00:00    
>>> 2012_02_25_11.log                                                                                                         100%   74KB  74.5KB/s   00:00    
>>> 2012_02_25_12.log                                                                                                         100%   75KB  74.6KB/s   00:00    
>>> 2012_02_25_13.log                                                                                                         100%   75KB  74.8KB/s   00:00    
>>> 2012_02_25_14.log                                                                                                         100%   75KB  74.9KB/s   00:00    
>>> 2012_02_25_15.log                                                                                                         100%   74KB  74.3KB/s   00:00    
>>> 2012_02_25_16.log                                                                                                         100%   74KB  74.5KB/s   00:00    
>>> 2012_02_25_17.log                                                                                                         100%   74KB  73.7KB/s   00:00    
>>> 2012_02_25_18.log                                                                                                         100%   74KB  74.1KB/s   00:00    
>>> 2012_02_25_19.log                                                                                                         100%   74KB  73.5KB/s   00:00    
>>> 2012_02_25_20.log                                                                                                         100%   75KB  75.2KB/s   00:00    
>>> 2012_02_25_21.log                                                                                                         100%   73KB  72.9KB/s   00:00    
>>> 2012_02_25_22.log                                                                                                         100%   74KB  74.1KB/s   00:00    
>>> 2012_02_25_23.log                                                                                                         100%   73KB  73.2KB/s   00:00    
>>> 2012_02_26_00.log                                                                                                         100%   77KB  76.9KB/s   00:00    
>>> 2012_02_26_01.log                                                                                                         100%   75KB  75.0KB/s   00:00    
>>> 2012_02_26_02.log                                                                                                         100%   76KB  76.0KB/s   00:00    
>>> 2012_02_26_03.log                                                                                                         100%   76KB  75.6KB/s   00:00    
>>> 2012_02_26_04.log                                                                                                         100%   76KB  76.3KB/s   00:00    
>>> 2012_02_26_05.log                                                                                                         100%   75KB  75.0KB/s   00:00    
>>> 2012_02_26_06.log                                                                                                         100%   75KB  75.5KB/s   00:00    
>>> 2012_02_26_07.log                                                                                                         100%   74KB  74.1KB/s   00:00    
>>> 2012_02_26_08.log                                                                                                         100%   74KB  74.4KB/s   00:00    
>>> 2012_02_26_09.log                                                                                                         100%   74KB  74.4KB/s   00:00    
>>> 2012_02_26_10.log                                                                                                         100%   75KB  74.9KB/s   00:00    
>>> 2012_02_26_11.log                                                                                                         100%   75KB  75.3KB/s   00:00    
>>> 2012_02_26_12.log                                                                                                         100%   75KB  74.9KB/s   00:00    
>>> 2012_02_26_13.log                                                                                                         100%   74KB  74.1KB/s   00:00    
>>> 2012_02_26_14.log                                                                                                         100%   74KB  74.1KB/s   00:00    
>>> 2012_02_26_15.log                                                                                                         100%   75KB  74.8KB/s   00:00    
>>> 2012_02_26_16.log                                                                                                         100%   74KB  73.5KB/s   00:00    
>>> 2012_02_26_17.log                                                                                                         100%   74KB  74.5KB/s   00:00    
>>> 2012_02_26_18.log                                                                                                         100%   74KB  74.1KB/s   00:00    
>>> 2012_02_26_19.log                                                                                                         100%   74KB  73.5KB/s   00:00    
>>> 2012_02_26_20.log                                                                                                         100%   74KB  74.5KB/s   00:00    
>>> 2012_02_26_21.log                                                                                                         100%   73KB  73.1KB/s   00:00    
>>> 2012_02_26_22.log                                                                                                         100%   74KB  74.1KB/s   00:00    
>>> 2012_02_26_23.log                                                                                                         100%   74KB  73.8KB/s   00:00    
>>> 2012_02_27_00.log                                                                                                         100%   77KB  76.6KB/s   00:00    
>>> 2012_02_27_01.log                                                                                                         100%   75KB  74.8KB/s   00:00    
>>> 2012_02_27_02.log                                                                                                         100%   74KB  74.4KB/s   00:00    
>>> 2012_02_27_03.log                                                                                                         100%   75KB  75.0KB/s   00:00    
>>> 2012_02_27_04.log                                                                                                         100%   76KB  76.1KB/s   00:00    
>>> 2012_02_27_05.log                                                                                                         100%   75KB  74.7KB/s   00:00    
>>> 2012_02_27_06.log                                                                                                         100%   75KB  75.1KB/s   00:00    
>>> 2012_02_27_07.log                                                                                                         100%   75KB  75.3KB/s   00:00    
>>> 2012_02_27_08.log                                                                                                         100%   76KB  75.8KB/s   00:00    
>>> 2012_02_27_09.log                                                                                                         100%   76KB  75.8KB/s   00:00    
>>> Warning: untrusted X11 forwarding setup failed: xauth key data not generated
>>> Warning: No xauth data; using fake authentication data for X11 forwarding.
>>> bml0041:shell_script janos$ 
>>> <nyassz>
>>>
>>> The delete also worked despite the warnings above.
>>>
>>> The reference to the files are absolute, so cron should find them.  It looks to me that cron is not lunched at all by the crontab entry:
>>> bml0041:shell_script janos$ crontab -l
>>> 10	*	*	*	*	/Volumes/Data/PROJECTS/Sysmon/shell_script/del_from_sequoia.ksh > /Volumes/Data/PROJECTS/Sysmon/shell_script/del.txt
>>>
>>> bml0041:shell_script janos$ ls -l
>>> total 32
>>> -rw-------@ 1 janos  admin  1799 Feb 10  2010 awk_commands (Autosaved)
>>> -rwxr-xr-x@ 1 janos  admin  2647 Jul  8  2010 awk_commands.sh
>>> -rw-r--r--  1 janos  admin     0 Feb 27 10:10 del.txt
>>> -rwxr-xr-x  1 janos  admin   128 Feb 23 16:48 del_from_sequoia.crontab
>>> -rwxr-xr-x@ 1 janos  admin   214 Feb 23 12:35 del_from_sequoia.ksh
>>>
>>> The del.txt file is empty, although it should have hourly outputs from last Thursday late afternoon.
>>>
>>> Thanks ahead,
>>>
>>> János
>>>
>>>
>>>
>>> On Feb 23, 2012, at 9:54 PM, Jerry wrote:
>>>
>>>> Hello János,
>>>>
>>>> I see that you state your scp and ssh command line(s) run fine manually.
>>>>
>>>> What happens when you run the whole shell script manually?  Does it (the
>>>> shell script) run?  If not, does it have execute permissions set?
>>>>
>>>> Are you running your script as your UID?  Or as root?
>>>>
>>>> Does your shell script need $PATH set from with in?
>>>>
>>>> and finally, at the end of your cron line, you have this
>>>>
>>>>> /dev/null 2>&1
>>>>
>>>> which is great once you have all the bugs worked out.  I am sure you
>>>> knew that.  Have you tried sending STDOUT and STDERR to a file, vs. the
>>>> bit bucket to trouble shoot your script.
>>>>
>>>> as far as the launchctl thing, I typically only use that for start up
>>>> items when the system is booting, or I am logging in as a user.  AFAIAK,
>>>> cron is where you need to be for repetitive system jobs.
>>>>
>>>> Jerry
>>>>
>>>>
>>>> On 02/23/12 03:06 PM, János Löbb wrote:
>>>>> Folks,
>>>>>
>>>>> I am sure I was sleeping at the wheel regarding this issue, so I need a hit on my neck to the right direction.
>>>>>
>>>>> I have this little crontab entry:
>>>>> bml0041:shell_script janos$ cat del_from_sequoia.crontab 
>>>>> 10 * * * * /Volumes/Data/PROJECTS/Sysmon/shell_script/del_from_sequoia.ksh > /dev/null 2>&1
>>>>>
>>>>> That is I want at 10 minutes after the hour to execute a shell script.
>>>>>
>>>>> The script is this:
>>>>>
>>>>> bml0041:shell_script janos$ cat del_from_sequoia.ksh
>>>>> #!/bin/bash
>>>>> #
>>>>> scp [email protected]:/prod2/ase15/sysmon/sysmonlogs/*.log /Volumes/Data/PROJECTS/Sysmon/sysmsa/
>>>>>
>>>>> ssh [email protected] "find /prod2/ase15/sysmon/sysmonlogs -name '*.log' | xargs rm "
>>>>>
>>>>> That is first I copy over some files from a remote server to my local machine followed by deleting the files on the remote server.
>>>>>
>>>>> If I do these two commends on the local machine at the CLI, both works fine.  However executing them via cron is a no go, that is nothing happens.
>>>>>
>>>>> Now, I see in man crontab, that it wants me to use launchctl and I looked its man page too, but I am not seeing how could I schedule the execution of this script with launchd.
>>>>>
>>>>> Thanks ahead,
>>>>>
>>>>> János
>>>>>
>>>>
>>>> _______________________________________________
>>>> MacOSX-admin mailing list
>>>> [email protected]
>>>> http://www.omnigroup.com/mailman/listinfo/macosx-admin
>>>
>>> _______________________________________________
>>> MacOSX-admin mailing list
>>> [email protected]
>>> http://www.omnigroup.com/mailman/listinfo/macosx-admin
>>
>> _______________________________________________
>> MacOSX-admin mailing list
>> [email protected]
>> http://www.omnigroup.com/mailman/listinfo/macosx-admin
> 
> _______________________________________________
> MacOSX-admin mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/macosx-admin