Hi Rolf, I suppose I should have been more accurate. I scripted a launchd plist and bash shell script. So here goes.
I was going to origingally tell you to just run your CRON job as sudo, but seeing as CRON is deprecated, I figured I'd give you the following properly apple way to create a scheduled task script that runs as root on system launch and run every night at 1:00am (system time)
I'll do this step by step.
1. Use Terminal and navigate to your LaucnhDaemons folder
cd /Library/LaunchDaemons
2. Create your launchd script (try and use apple naming conventions to avoid file conflicts)
sudo touch com.yourname.restartslapd.plist
3. Edit the file as root (you can use vi, or vim, I prefer to use nano)
sudo nano com.yourname.restartslapd.plist
4. Enter in your launchd configurations (make sure your Label matches your filename).
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.yourname.restartslapd</string>
<key>ProgramArguments</key>
<array>
<string>/Users/Shared/scripts/killstartslapd.sh</string>
</array>
<key>Nice</key>
<integer>1</integer>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>1</integer>
</dict>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/restartslapd.err</string>
<key>StandardOutPath</key>
<string>/tmp/restartslapd.out</string>
</dict>
</plist>
5. Create your script (be sure to use sudo when you create it so that root can run it)
/Users/Shared/scripts/killstartslapd.sh
#!/bin/bash
date >> /tmp/restartslapd.out
echo "restarting slapd..."
pkill slapd
sleep 5
/usr/libexec/slapd -d 255
echo "completed!"
6. Add your plist into launchctl as sudo.
sudo launchctl load com.yourname.restartslapd.plist
7. You can check to see if your daemon is running with this command.
sudo launchctl list
Also back in the CRON days (all of just a year or two ago lol). You simply just used "sudo cron -e" and removed sudo from your scripts (because root is already evoked by cron before your scripts ran anyways).
I hope this helps you out, and sorry about the late reply. I didn't want to give you a solution using a deprecated process on your mac.