There are actually two ways you can do this.
Modify the script method
Locate and modify the script that runs the SaltStack update. It could be something like bootstrap-salt.sh
, but it could be anything. Try looking for it in your process list while the update is running (ps -ef |grep -i salt
). it should be something with .sh at the end. Once you have located the script, you can insert at the top of the script a line that disables cron. This is the safest method.
This can be either of the following:
/etc/init.d/crond stop
or
crontab -l -u root > /root/cron.bak
crontab -r -u root
Note: The later only works on the user you list and is dependent how you are managing cron. For example, this method will not disable any jobs listed in /etc/cron.daily/ cron.hourly/ cron.monthly/ or cron.weekly/
. If you decide to use this method, it would be best to actually identify the process you do not want running at the same time as your SaltStack update and disable the cron which runs that process specifically.
Then at the end of the script one of the following:
/etc/init.d/crond start
or
crontab -u root /root/cron.bak
Run a daemon method
Write a script that runs as a daemon to check for a running process, but this is less reliable and would have a chance to miss during the time gap while the script loops. The only way to mitigate it would be to just loop it without a sleep, but again, that's not really advised. I would use this method only as a last resort if you are unable to locate or modify the script that launches the update for SaltStack.
The daemon script would look something like this:
#!/bin/bash
while true
do
# this might have to be tweaked based on the process you are looking for
SaltUpdateRunning=$(ps -ef |grep -v grep |grep -i salt |grep -i update | wc -l)
if [ $SaltUpdateRunning -gt 0 ]
do
/etc/init.d/crond stop
sleep 3600 # 1 hour just to be safe - you can modify to
# match the runtime of SaltStack update
/etc/init.d/crond start
done
sleep 1 # this is for safety but you can remove and it will loop
# much faster with less chance to miss the running process
done
You should also look into SaltStack's ability to manage cron. I am not sure if there is a way for it to automatically disable cron or certain processes while the update is running, but it wouldn't hurt to dig a little deeper into it's abilities.