Find the answer to your Linux question:
Results 1 to 4 of 4
I ran into a problem when wanting to execute the "at" command from within a cron job. Essentially, I have a daily crontab job that is launched at "the wrong ...
  1. #1
    Just Joined!
    Join Date
    Mar 2011
    Posts
    2

    Problems running "at" command within a cronjob

    I ran into a problem when wanting to execute the "at" command from within a cron job.

    Essentially, I have a daily crontab job that is launched at "the wrong time" (middle of night). I want to delay the execution of an import script until around 07:00. Editing the crontab is not an option (shared environment).

    So I figured: Use the "at" command from within my script that is triggered (indirectly) by crontab:
    Code:
    #!/bin/bash
    at -f ./redo_import.sh -v 07:00
    I know my script is started with `pwd` pointing at that same directory.

    Running the "at" command directly from terminal works.

    Running the script file above from terminal works.

    But... when triggered from within crontab it does not work. I get exit code "1" from "at".

    I searched man pages for "at" without much success. No mention of meaning of exit codes.

    Now I wonder if someone has an idea why this is happening. Or how to locate the sources of the "at" command.

    Thanks.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,977
    Just a guess, but sometimes this sort of problem is due to the detached nature of the processes shell started by cron (no stdin/stdout/stderr). You might try redirecting the input and output of the 'at' command inside your script to see if that helps.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Mar 2011
    Posts
    2

    Solved

    I got some help locally and of course answer was easy.

    "at" only reported to stderr and I was not logging that. Only the exit code, which could mean anything.

    The current path (pwd) inside the cronjob was not what I expected. When cactching stderr message... it was easy to solve.

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,977
    So, basically what I said... Glad you got it sorted out.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...