Cron job not running - script uses rsync, ssh (with id_rsa)

Does anyone know how to get cron to run a rsync/ssh script which uses id_rsa for passwordless logins?
I have a backup script I have slaved for months over that works wonderfully when running it from the command line.
It uses rsync and connects with SSH (passwordless using ssh keys). I have setup id_rsa and id_rsa.pub for passwordless logins (this is my user account, and connects using root@ to the server)
As stated all works find when run from the command line. But when I setup a cron job to run this file (exact same line I run from the command line) it does not execute. Actually, it does run, as I have an email notifiction which sends to me. It is just the rsync/ssh part that does not run.
I have spent days and days trying to figure it out. No error messages occur, nothing.  Took me a while to find out cron is emailing the user account on Lion the messages (not to a proper email address).
The error shows a permission denied, which I believe to be the cron user cannot use the id_rsa/ssh connection.
Cron is running the script as my user, the same I use on the command line. I even tried copying the id_rsa to the root user .ssh folder in case cron is running as root but that does not work either.
So does anyone know how to get cron to run this rsync/ssh script which used id_rsa for passwordless logins?
Thanks a lot

YES! Got it working, finally!
So the issue is indeed cron/launchd not being able to access the ssh-agent which holds the key.
So this is the solution...
Download keychain for Mac:
http://www.funtoo.org/wiki/Keychain
Then once its installed and configured, the script to run needs this added to the top:
eval `keychain --noask --eval id_rsa` || exit 1
Note I am using id_rsa whereas keychains instructions refer to id_dsa so I just changed it and it works OK.
When the script runs the first time it asks for the key password. Then it works from then on.
What I do not know yet is will I need to re-enter the password when I logoff/logon again. That will cause an issue as I auto restart the Mac every day which means if I am off for a few days backup will stop (can you see the madness in this issue!).

Similar Messages

  • Cron jobs not running

    Hi
    I am using linux 5.x
    uname -r
    2.6.18-348.16.1.0.1.el5PAE
    I have 2 crontab jobs set up as following .
    cat backup_confluence.sh
    #!/bin/bash
    # bash shell script to backup confluence backups to bccpfr
    # Schedule this script after the backups are performed that day
    # Setup the environment for the bourne-again shell
    . ./.bash_profile
    # Copy the daily backups for confluence
    find /usr/share/confluence/data/backups -mtime -1 \! -type d -exec ls {} \; -exec scp {} bccpfr:/usr/backup/confluence \;
    second
    cat  backup_jira.sh
    #!/bin/bash
    # bash shell script to backup jira backups to bccpfr
    # Schedule this script after the backups are performed that day
    # Setup the environment for the bourne-again shell
    . ./.bash_profile
    # Copy the daily backups for jira
    find /usr/share/jira/backups -mtime -1 \! -type d -exec ls {} \; -exec scp {} bccpfr:/usr/backup/jira \;
    cron as following
    $ crontab -l
    13 06 * * * /home/lsg/backup_jira.sh
    18 06 * * * /home/lsg/backup_confluence.sh
    Issue
    Both the above .sh are running properly when executed  manually but they are not running automatically at the given time crontab job.
    Kindly help me on this issue.
    many thanks
    J

    Is your crontask not running at all or is the scheduled task failing?
    Hey Tommy I sent you some replies yesterday; don't know what happened to them. Yes I can see that crond runs every ten minutes. Also when I created the crontab file using the command you sent here I could see that it was running every minute by looking at root mail in /var/log.
    Do you have execute permission set on the scripts?
    Yes
    Any info in /var/log/messages or e-mail?
    Output from mail-
    From root@razorback  Tue Feb 11 08:19:01 2014
    Return-Path: <root@razorback>
    Received: from razorback (localhost [127.0.0.1])
        by razorback (8.13.8/8.13.8) with ESMTP id s1BEJ154018231
        for <root@razorback>; Tue, 11 Feb 2014 08:19:01 -0600
    Received: (from root@localhost)
        by razorback (8.13.8/8.13.8/Submit) id s1BEJ1rh018198;
        Tue, 11 Feb 2014 08:19:01 -0600
    Date: Tue, 11 Feb 2014 08:19:01 -0600
    Message-Id: <201402111419.s1BEJ1rh018198@razorback>
    From: root@razorback (Cron Daemon)
    To: root@razorback
    Subject: Cron <root@razorback> $(date) >> /tmp/cronout
    Content-Type: text/plain; charset=UTF-8
    Auto-Submitted: auto-generated
    X-Cron-Env: <SHELL=/bin/sh>
    X-Cron-Env: <HOME=/root>
    X-Cron-Env: <PATH=/usr/bin:/bin>
    X-Cron-Env: <LOGNAME=root>
    X-Cron-Env: <USER=root>
    /bin/sh: Tue: command not found
    From root@razorback  Tue Feb 11 08:20:02 2014
    Return-Path: <root@razorback>
    Received: from razorback (localhost [127.0.0.1])
        by razorback (8.13.8/8.13.8) with ESMTP id s1BEK2BD018267
        for <root@razorback>; Tue, 11 Feb 2014 08:20:02 -0600
    Received: (from root@localhost)
        by razorback (8.13.8/8.13.8/Submit) id s1BEK1mT018238;
        Tue, 11 Feb 2014 08:20:01 -0600
    Date: Tue, 11 Feb 2014 08:20:01 -0600
    Message-Id: <201402111420.s1BEK1mT018238@razorback>
    From: root@razorback (Cron Daemon)
    To: root@razorback
    Subject: Cron <root@razorback> $(date) >> /tmp/cronout
    Content-Type: text/plain; charset=UTF-8
    Auto-Submitted: auto-generated
    X-Cron-Env: <SHELL=/bin/sh>
    X-Cron-Env: <HOME=/root>
    X-Cron-Env: <PATH=/usr/bin:/bin>
    X-Cron-Env: <LOGNAME=root>
    X-Cron-Env: <USER=root>
    /bin/sh: Tue: command not found

  • Convert Spool to PDF and mail for the jobs not run in background.

    Dear All,
    I need to convert the spool job into pdf and mail as attachment for job not run in background.
    I am printing the bills  using the program  SD70AV3A to print the bills in a batch using the SUBMIT.
    But i am not using the spool options since its going to into waiting state in spool...and i need to change the printer properties to G
    to get the printer to print the reports as these jobs run in backgroud....but this solution is not acceptable solution.
    SUBMIT SD70AV3A
             WITH RG_KSCHL-LOW = 'ZRR'
             WITH RG_NACHA-LOW = '1'
             WITH PM_VERMO = '2'
             WITH PM_NSORT = '1'
             WITH RG_VBELN IN range.
    *        TO SAP-SPOOL
    *        SPOOL PARAMETERS print_parameters
    *        WITHOUT SPOOL DYNPRO
    *        VIA JOB name NUMBER number
    *        AND RETURN.
    so how do i get the spool number from the above after the job is submitted....and then convert into pdf and mail
    please suggest some solution. I have searched on net but most the solutions are say to run the job as background job...
    i have also looked into the program RSTXPDFT4 but it asks for the spool id ....how can i get spool id for the job that has been completed.
    please suggest some solution.
    Thanks
    Bhargava.

    Hi,
    Spool to PDF : FM 'CONVERT_ABAPSOOLJOB_2_PDF'
    Table TSP01 to get spool number
    You ,may need to convert OTF to PDF: FM CONVERT_OTF
    and the to binary : FM 'SMCS_XSTRING_TO_BINARY'
    To send mail use class: cl_document _bcs.
    Regards,
    Maria João Rocha

  • How to run tests in Firefox when running script using runScript.bat

    I am trying to run OATS script from commandline without opening Openscript IDE(eclipse). I use the following command to execute my script:
    runScript "<scriptpath>/<scriptName>.jwg"The script starts to execute and launches IE. I wanted to run my test on Firefox but it always launches IE even if Firefox is my default browser.
    If I run my script from Openscript IDE it honours the Browser settings in View > OpenScript preferences... OpenScript > General > Browsers. When running thorugh cmd line, these settings are not taken into account as Eclipse preferences settings are applicable only for the workspace selected for the IDE.
    Any thought on how to set these preferences when running scripts using runScript.bat file?
    Thanks,
    Manish Khatre

    Hello
    You need to pass the value/parameters (preferences) to the command line as documented in the OpenScriptUserGuide.pdf.
    Something like
    -browser.type type
    Specify the browser type to use for script playback
    where type is one of the following (use exact case
    and no spaces):
    ■ InternetExplorer
    ■ Firefox
    The default is InternetExplorer
    JB

  • CRON did not run, how do I check ?

    I defined the cron jobs :
    crontab -e
    01 14 * * * /bin/sh /mydir/disk_mon.sh
    01 14 * * * echo 123 >> /mydir/a.txt
    these can be seen by crontab -l
    But obviously the cron did not run.
    log in as root, i'm able to see the crond service is running.
    There is no /ect/cron.allow file
    the /etc/cron.deny is empty
    What eles I can check?
    Thanks

    it was typo. i do not have /etc/cron.allow
    OS infor:
    uname -a
    Linux adcdak05 2.6.18-164.0.0.0.1.el5 #1 SMP Thu Sep 3 00:21:28 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
    # cat /etc/pam.d/crond
    # The PAM configuration file for the cron daemon
    auth sufficient pam_rootok.so
    auth required pam_env.so
    auth include system-auth
    account required pam_access.so
    account include system-auth
    session required pam_loginuid.so
    session include system-auth
    alll lines are commented out in /etc/security/access.conf
    Please help. thx

  • Full page prints from iPhone but not from iPad using photo app with AirPrint ?

    Full page prints from iPhone but not from iPad using photo app with AirPrint ? iPad only prints 4x6 on full size paper. It's an HP 8600.

    I also have this problem printing photos from an iPad to an Epson WF-2540 printer. It prints only 4x6 and without border (so print starts at extreme top left corner of paper). Borderless printing is not selected on printer. Printing a square photo just crops to 4x6 size.

  • I m working in an organization where web-sense is installed to block all irrelevant sites, i have installed itunes but it does not run a window pops up with message 'itunes is not connected to the network' can anyone help me out?

    i m working in an organization where web-sense is installed to block all irrelevant sites, i have installed itunes but it does not run a window pops up with message 'itunes is not connected to the network' can anyone help me out?

    There's a whole lot to read in your post, and frankly I have not read it all.
    Having said that, this troubleshooting guide should help:
    http://support.apple.com/kb/TS1538
    In particular, pay attention to the mobile device support sections near the bottom, assuming you have already done the items above it.

  • 2nd Try: Please Help : UIX : Not able to use messageFileUpload along with m

    UIX : Not able to use messageFileUpload along with messageChoice
    I used messageFileUpload UIX element and associated upload button to fileupload servlet. This servlet just captures the file and put it in desired location. This works just fine.
    My client wanted me to add another choice filed on UI. I used messageChoice. I named the field as fileType. All the options have name and value populated but when I submit the form servlet is reading fileType as NULL.
    I am not sure what's happening. Please let me know how should I send file handle as well fileType ?
    Thanks,
    Linda

    What exactly are you expecting this to do for you?
    Forall is designed to process batches of DML to prevent context switching from PL/SQL to SQL.
    Has no relevance for what you are trying to do.
    If you don't want to call the procedure multiple times, you need to rewrite it to passs the cursor to the function, then have the function process all the records.
    Carl

  • Running Applescript using cron jobs not working

    I'm new to conjobs and applescript but I have the script done correctly i believe. (any critique is welcome) I don't want to bloat my calendar with events to do this because I use my calendar for appointments and I don't need the bloat.
    Here's my goal: run an apple script at 9am/5pm to enable/disable a mail account (after this works I'm going to add loging in/out of an Messenger account, first things first)
    here's my script:
    tell application "Mail"
              set offTime to 17
              set onTime to 9
              set dayOfWeek to weekday of (current date)
              set theHour to get the (hours of (current date)) as string
              if theHour ≥ onTime then
                        say "email on"
                        set enabled of account "MAILBOX" to true
              else if theHour ≥ offTime or (dayOfWeek = Saturday or dayOfWeek = Sunday) then
                        say "email Off"
                        set enabled of account "MAILBOX" to false
              end if
    end tell
    accessing cron jobs via this
    sudo pico /etc/crontab 
    and within cron jobs i've used
    0 9 * * * username osacript
    "/Documents/disablemail.scpt"
    0 17 * * * username osacript
    "/Documents/disablemail.scpt"
    variations I've attempted (based on search engine results)
    0 9 * * * username osacript
    "~/Documents/disablemail.scpt"
    0 9 * * * /Documents/disablemail.scpt
    0 9 * * * ~/Documents/disablemail.scpt
    0 9 * * * osacript /Documents/disablemail.scpt
    0 9 * * * osacript ~/Documents/disablemail.scpt
    I think that's all of them.
    Any feedback/assitance appreciated, thanks!

    What's the problem, is the cronjob not getting called at all or is the script giving errors?
    One problem you have right off is the cron job you have set up is running as root not as you.

  • Cron jobs not always run

    I have cron jobs which do not always run. Has anyone had this problem. These are simple executables which may run one day, but not the next. Very puzzling.

    415/2861
    Here's in detail how/why it works this way
    (and so far still the same in 10.4.4 I think):
    A simple example:
    http://discussions.apple.com/message.jspa?messageID=1320152#1320152
    Peter Sealy:
    http://discussions.apple.com/message.jspa?messageID=1384836#1384836
    Dr. Smoke:
    http://discussions.apple.com/message.jspa?messageID=1362594#1362594
    The problem is that they are delayed by sleeps.

  • Oracle Job not running properly

    Hi All,
    I am facing an issue with oracle jobs.
    I have writtent the script of a job scheduled to be executed automatically after 2 seconds.It works on a table and dequeue the data in that table.
    Now the job is not able to execute for next time.If i execute the job immediately then also it does not run for next time.
    so where could be the problem...
    Please give me pointers.
    Thanks in advance :)
    Thanks n Regards
    Arun

    user10280915 wrote:
    Hi All,
    I am facing an issue with oracle jobs.
    I have writtent the script of a job scheduled to be executed automatically after 2 seconds.It works on a table and dequeue the data in that table.
    Now the job is not able to execute for next time.If i execute the job immediately then also it does not run for next time.
    so where could be the problem...
    Please give me pointers.
    Thanks in advance :)
    Thanks n Regards
    ArunThings that you'll need.
    1. JOB_QUEUE_PROCESSES to be non-zero
    2. A commit after submitting the job
    3. The job not to be broken.
    4. don't schedule very frequently (say <5s) if the os is Linux :( ).
    I'd check in the above order.
    Niall

  • Not run script in policy

    hi i have a bach file run .bat
    this is in network \\dc\data
    but wen run this file of this way , not run
    i must map this way and run it to correct
    now i create setup.bat  and it whole
    ======
    net use  t: \\ dc\data
    t:
    call run .bat
    ====
    when run setup.bat, map t, and run corect
    now i create a policy and in script shutdown place the file setup.bat
    but when shutdown pc,the shut down is very time and script not run
    of corce a later 6 moon befor update windows , this policy work ok
    ploease help me

    no body to help me

  • Jobs not running anymore since midnight

    All my jobs that run minutely, half minutely, 10 minutely, hourly are all last run tonight before midnight.
    Next run date was set to the correct time after midnight but they did not start.
    Its a rac database under 64bit windows, 10.2.0.3.
    Its acutally two databases and on one stopping and starting instances one by one helped.
    On the other one the jobs (at least did run, or at least the next run data got updated) by the starting and stopping instances, but they still do not run at there regular intervals.
    Currently i am trying with one job, disabling, enabling, changing the schedule, it runs occassionaly but not ever half minute as it should.
    I did all the checks, no jobs running, there are not too many sessions, the job_queue parameters are correct....
    There is nothing in the alert log, only thing i can find is:
    jsksGetCurWindowId:1 got error 27468
    in the cjq0 logfile.
    Any further ideas or sugestions ?

    Do you use Oracle Scheduler (DBMS_SCHEDULER)?
    If yes...
    select * from DBA_SCHEDULER_GLOBAL_ATTRIBUTE where attribute_name='CURRENT_OPEN_WINDOW';
    What do you find "Window group"?
    If you find and then close it...
    Example:
    SQL> select * from DBA_SCHEDULER_GLOBAL_ATTRIBUTE where attribute_name='CURRENT_OPEN_WINDOW';
    ATTRIBUTE_NAME VALUE
    CURRENT_OPEN_WINDOW WEEKNIGHT_WINDOW
    SQL> exec DBMS_SCHEDULER.close_window ('WEEKNIGHT_WINDOW');
    If you use dbms_job, then try
    SQL> show parameter job_queue_processes
    NAME TYPE VALUE
    job_queue_processes integer 50
    SQL> alter system set job_queue_processes=0;
    SQL> alter system set job_queue_processes=50;
    surachart
    http://surachart.blogspot.com

  • Job not running on expected time

    Hi,
    Please see the job details
    X NUMBER;
    BEGIN
    SYS.DBMS_JOB.SUBMIT
    *( job => X*
    *,what => 'BEGIN INVS_RIM_DATA_LOAD(''01A'',''RIMADMIN'',TRUNC(SYSDATE)); END;'*
    *,next_date => to_date('15/08/2011 23:09:00','dd/mm/yyyy hh24:mi:ss')*
    *,interval => 'TRUNC(SYSDATE+1)+23.15/24'*
    *,no_parse => TRUE*
    SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
    END;
    commit;
    For taking the cold backup, db is shut down on every Friday 11:00PM and open by 02:30 PM Saturday. So job expected to run on Friday night will be running by Saturday 02:30AM. It is ok for us. But problem is job is not running on Saturday night.
    When checked on Sunday morning the user_jobs shows details as
    Last_date : 13-Aug-2011 02:30:14 AM
    Next_Date : 14-Aug-2011 11:09:00 PM
    Issue we are facing is job is not running on 13-Aug 11:09:00 PM
    Please help me to fix this issue.

    Well, it runs on the expected time (for me). This is your interval: TRUNC(SYSDATE+1)+23.15/24
    If the last job run at 13-Aug-2011 02:30:14 AM, then the next one should be:
    = TRUNC( '13-Aug-2011 02:30:14 AM' + 1 ) + 23.15/24
    = TRUNC( '14-Aug-2011 02:30:14 AM' ) + 23.15/24
    = '14-Aug-2011' + 23.15/24
    = '14-Aug-2011 11:09:00 PM'
    You can create an additional job which will work at Saturday nights. This is the easiest fix I can think.
    Regards
    Gokhan Atil

  • SQL Server Agent Jobs- Not running

    Team,
    We have a production database hosted on SQL Server 2008R2 SP2(10.50.4000). We have application jobs which are scheduled and basically have packages called from this job. These jobs were running all good till yesterday and it has stopped working since yesterday
    even though its enabled. Manual runs are successful. Other jobs are running fine. 
    Checked the Owner of these jobs and the account is SQL Server account which is a proxy account. It had enforce password policy. I have removed that and reset the password to original. However it didnt work.
    The last change on this server was windows patching which was performed last week. Apart from that the SQL Server agent service was changed. This is a clustered environment.
    The last resort is restart the agent, however would like to get some inputs before I perform this action. 
    Please let me know your valuable inputs.
    Regards,
    Sharath

    If job is not executed at all, that is, there are no entries in the job history, check:
    1) The job is enabled.
    2) The schedule(s) is enabled.
    3) The scdedule does not have an end date has has passed.
    4) And that all other conditions on the schedule says that the job should run.
    Erland Sommarskog, SQL Server MVP, [email protected]

Maybe you are looking for

  • How do I access my iCloud content? Specifically movies purchased in itunes.

    How do I access my iCloud content? Specifically movies purchased in itunes. I have multiple Apple devices, one itunes account, one cloud...purchased upgraded storage. The iCloud page on Apple website states that movies purchased in itumes are automat

  • SAME EJB 3.0 Stateful Session bean for different JSP sessions returned

    Forum, I have a strange problem utilizing stateful session beans. Please note, that I am using jdeveloper for the following: 1) Here is a basic stateful session bean: @Stateful(name = "DemoClass") public class DemoClassBean implements DemoClass,     

  • External harddisk became extremely slow after reformat using disk utility

    hello everyone~ let me try to describe as clear as possible! to start with, i have 2 external harddisk: hd(A)-120G, format in Mac OS Extended (journaled), it's and old harddisk and is nearly full; hd(B)-200G, format in MS-DOS (ie. FAT32), it's a new

  • Sort photos

    Can someone tell me how to resort photos in an album on iPad air? Tried to drop and drag but that doesn't work.  Any way to name each photo? Thanks. The photos are all screenshots taken on the iPad.

  • Database vs application users

    Hi. Please give some opinion on this: Wich is the best approach for managing users in a typical three-tier web application, using jdbc: A) The database has one or two users with the proper grants and privileges to manage data(eg. read_user for select