Yes, there are two ways to schedule a SQL Expert to run automatically on a specific day and time:
1. Using the “Sampling Rate” Setting
In the General tab of your SQL Expert configuration, set the Sampling rate (sec) to
604800(which equals one week).The Expert will trigger once every week, starting from the exact time it was deployed.
To ensure it runs at a specific time (e.g., Saturday at 1:00 AM), simply deploy the Expert at that time.
2. Using a Shell Script with a Cron Job and the apnet Utility
You can automate the execution of a SQL Expert by writing a script and scheduling it with cron:
Step 1: Create a shell script (e.g., run_expert.sh):
#!/bin/bash /path/to/apnet start sql_expert_name echo "$(date): Expert started via apnet" >> /var/log/run_expert.log sleep 600 # Adjust based on how long the Expert takes to run /path/to/apnet stop sql_expert_name echo "$(date): Expert stopped via apnet" >> /var/log/run_expert.log
Step 2: Make the script executable:
chmod +x /path/to/run_expert.sh
Step 3: Schedule it using cron to run at 1:00 AM every Saturday:
crontab -e
Add the following line:
0 1 * * 6 /path/to/run_expert.sh >> /var/log/run_expert_cron.log 2>&1
Replace /path/to/apnet and
sql_expert_name with actual values.
Ensure the user running the cron job has sufficient permissions to execute
apnet.