• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 616
  • Last Modified:

UNIX (AIX) Cron Daemon

I've been told that the crontab file should not contain "commands." I believe they were referring to binaries versus batch; the implication being that batch files (i.e., scripts) are preferable. I am aware of no such restriction. I know that for some commands there are both transient (binary files) and shell built-ins (i.e., compiled into the shell). Regardless, I've never seen cron complain. What am I missing?
1 Solution
Obviously nothing.

Cron will execute any valid command for you, be it a script or a binary.
Since these "commands" are executed within a shell opened by cron you can also use builtins and shell keywords.

Please note that under AIX this shell is /bin/sh which is a hardlink to /bin/ksh, so you can only use those builtins recognized by ksh.

This restriction is not as hard as it might sound - many builtins have their binary equivalents, e.g. "echo" or "test".

As an example - I often use things like

* * * * * [ -d //dir/containing/scripts ] && /dir/containing/scripts/myscript

As you can see, even things like "[" (a builtin equivalent to "test") or "&&" work under cron.
I could also have used "if", "then" (shell keywords) and it would have worked.

So trust in cron and don't worry!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now