4 Replies Latest reply on Dec 2, 2016 8:18 AM by JEDtech

    System level scripts runs on macOS but never terminates

    nielscastle

      I am installing a fresh FileMaker 15.0.1.137 on macOS El Capitan 10.11.6 (15G31) and I want to schedule a system-level script to run periodically.

       

      I have created the schedule

       

      Schedule type: System Script

      Schedule name: Scheduled items

      Script name filemac:/Macintosh HD/Library/FileMaker Server/Data/Scripts/scheduled_items.sh

      Script parameter

      Script time limit (hh:mm) 00:01

      Abort at time limit Enabled

      Frequency Daily

      Start date 9/12/16 1:17 AM

      End date None

      Repeat Run every day, Every 1 Hours 1:17 AM – 11:57 PM

      Email notifications Enabled

      Email addresses me@hello.dk

      Schedule Enabled Enabled

       

      The script just touches a file in /tmp

       

      #!/bin/sh

      touch /tmp/did_run.txt

       

      I can see the file appearing in /tmp but the script is always terminated when reaching the time limit. I have tried 1 minute as well as 5 or 10 minute time limits. In the Admin Console the status is listed as

       

      Aborted unexpectedly

       

      And the log and e-mail sent contains the same information

       

      2016-09-12 16:18:00.038 +0200   Error   642     FileMaker Server    Schedule "Scheduled items" aborted; unexpected error. (10022)

       

      If I don't set a time limit the execution appears to continue indefinitely.

       

      How can I make the scripts terminate nicely so I can differentiate real schedule errors from the false positives?

        • 1. Re: System level scripts runs on macOS but never terminates
          user19752

          Did you remove the /tmp/did_run.txt file before run schedule?

          "Aborted" can be caused by schedule can't overwrite the file, if you run the script when logged in as some user other than fmserver.

          • 2. Re: System level scripts runs on macOS but never terminates
            nielscastle

            Good suggestion - I have tried removing the file before running and the result is the same. I have also tried removing the old file as the first thing in the script.

             

            #!/bin/sh

            rm -f /tmp/did_run.txt

            touch /tmp/did_run.txt

             

            All the scripts are running as fmserver and the file is created with read and write rights for fmserver. It seems fmserver is able to remove the file or overwrite it.

             

            The problem also persists if I create a script that does not create a file, e.g. just echoes a bit of text.

             

            Are there any best practices for debugging schedules? Besides logging from within the script which focuses on the script side of things and not FileMaker?

            • 3. Re: System level scripts runs on macOS but never terminates
              JeffHenry

              Hi Niel,

               

              I'm currently trying to write a shell script to simply open a file and I'm getting the same 10022 error. I test the shell script file via terminal and it behaves as expected, but when its ran via FMS, It aborts unexpectedly.

               

              I made sure permissions were fine on the file as well as tried adjusting the schedule to run with a particular user. Same error.

               

              Here is my script:

               

                   #!/bin/bash

                   open ~/Desktop/Routine.app

               

              Figured I would share a script I'm trying to run to see if we can narrow this down to an issue with FMS 15 or with our scripting. I tried a simple echo script as well. Same issue.    

               

              I also noticed that after my script schedule fails, I have to edit it and save it before I can attempt to run it again. Otherwise, if I try and run it, it never goes to a "running" state and stays as "Aborted Unexpectedly".

               

              Best,

              Jeff

              • 4. Re: System level scripts runs on macOS but never terminates
                JEDtech

                We had seen this problem in the past but it went away in FileMaker Server 15.0.1.  It is back in FMS 15.0.3 running on Mac OS X 10.10.5 Yosemite.

                 

                I built a new test script:

                #!/bin/bash

                exit 0

                 

                and set it up as a FileMaker schedule with a time limit of 2 minutes and to terminate after the time limit.  It should have run almost instantly but instead it ran out the clock and threw the same error 642 with Unexpected error 10022.