You must use an absolute path with
sudo, for security reasons:
( sudo /var/www/symmetric-ds-3.1.6/bin/sym --port 8082 --server );
Check the output of
sudo -l to confirm. From the
sudoers man page (1.7.x):
Cmnd_List is a list of one or more commandnames, directories, and
other aliases. A
commandname is a fully qualified
filename which may
include shell-style wildcards (see the Wildcards section below).
sudo xargs works because
xargs is (almost certainly) found in a trusted path (
Also, check out
pkill, it will save you the needless
ps pipe acrobatics.
You have the potential for resource leaks and other unwanted behaviour with an unconditional
kill -9, see http://unix.stackexchange.com/questions/8916/why-not-kill-9-a-process .
Update you've added that you run this via root's crontab -- root has no need to use
sudo, and in some cases root may be prevented from running
sudo, check what
sudo -l says when you are root. If you want to to be able to start a program (that doesn't switch its own uid) as a specific userid then the common way is
su - username -c "command" .