i’m using the following ant script to remove a crontab on a remote machine:
<target name="remove-crontab">
<echo message="Removing Crontab" />
<sshexec host="${host}" username="${username}" password="${password}" command="crontab -r" trust="true" failonerror="false" />
</target>
When I run the script, even if there is a crontab under the username I get no crontab for username
My only guess is the when connected through SSH some privileges are taken. Anyone know what’s this about ?
Thanks.
Make sure that a crontab file exists for that user in
/var/spool/cron/and check to see if its owner/group and permissions are correct:A solution to your issue may be to just empty the crontab by directing /dev/null into it instead of using
-r. This would ensure that the cron jobs are removed, but the crontab file doesnt get deleted from /var/spool/cron (the -r option just deletes this file, which is why the second time you run crontab -r, it says no crontab for user)::
I’m not sure, but
command="crontab < /dev/null"might need to becommand="crontab < /dev/null".