When I tried to get crontab to execute one of my mono compiled assemblies it failed with the error of not being able to resolve the assembly. The problem, after some investigation boiled down to the very simple fact of it not executing the script from the expected working directory. Easy enough to fix, just have crontab execute a cd into the working directory, and from there, execute with a relative path. Problem solved.
This is the shell script that I’m invoking from crontab:
#!/bin/sh mono --runtime=v4.0.30319 MonoDaemon.exe "/home/username/project/worker/logs"
And this was my initial crontab entry:
*/15 * * * * /home/username/project/worker/my-daemon.sh
And this is the way to get it to actually execute from the expected working folder:
*/15 * * * * ( cd /home/username/project/worker && ./daemon.sh )
Notice the parenthesizes and the &&, this allows cron to first switch directory followed by executing the script. Problem solved!
So if you ever have problem scheduling a Mono executable from crontab, check your expected working folder to allow the mono runtime to be able to resolve your assemblies properly.