• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: help requested with cron-executed shell script in Linux
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help requested with cron-executed shell script in Linux


  • Subject: Re: help requested with cron-executed shell script in Linux
  • From: Christopher Nebel <email@hidden>
  • Date: Wed, 12 Apr 2006 19:34:51 -0700

On Apr 12, 2006, at 3:35 PM, Dan Feather wrote:

The first command I wrote works fine on my Mac from Terminal, but Linux
compains that "-delete" is not acceptable. ::


find /symlnks/io/jobs/ -name '._*' -delete

[ finds and delete files whose name start with "._" ]

So, I try using a call to a built-in (-exec) and the rm utility, thus:

find /symlnks/io/jobs/workflows5/dalim4/ -name '._*' -exec rm ;

(As a line in the crontab file, it is:
0    *    *    *    *    find /symlnks/io/jobs/ -name '._*' -exec rm ;
)

However, the output now says: "missing argument to '-exec' "

Can anyone spot the problem?

Maybe. It's not clear to me exactly how cron(8) executes the command, so I can see two potential problems:


1. If the command is executed by a shell and not directly, you have to escape the semicolon, otherwise the shell sees it as a command separator. The correct syntax (at least on Mac OS X) would be "-exec rm \;".

2. You didn't specify what to rm. On Mac OS X, this is allowed -- the matching file is assumed to go after the command -- but Linux may require you to be explicit and mark the file using "{}". On Mac OS X, it would be "-exec rm {} \;"

As a side note, -exec is inefficient for large numbers of found files, since it will create a new process for each file. A more efficient way is to use xargs(1), like this:

	find ... -print0 | xargs -0 rm

Be sure to use the "-print0/-0" pair or else it won't work right with files that have spaces in their path.

Also, be aware that trashing "._" files will destroy various preferences, notably Finder view settings, and depending on the filesystem (read: anything but HFS+) can even effectively destroy certain types of files. You probably knew that already, but it's a good bet that some of your users don't. If the only problem is the ".DS_Store" files, then it's possible to get the Macs to not create them in the first place -- see <http://docs.info.apple.com/ article.html?artnum=301711> for instructions.


--Chris Nebel AppleScript and Automator Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >help requested with cron-executed shell script in Linux (From: Dan Feather <email@hidden>)

  • Prev by Date: Re: Text Item Delimiter Problem
  • Next by Date: Re: Replace names of files in different folders
  • Previous by thread: help requested with cron-executed shell script in Linux
  • Next by thread: HTML all broken up in Entourage
  • Index(es):
    • Date
    • Thread