Yes, it is possible (and very probable).
A crude solution is to instruct your script to sleep some time. For example, change your cron line as below:
* * * * * sleep 60; python script.py
This will wait 60 seconds, which should give MySQL time to start.
If you had to be absolutely sure that mysql process started before your script runs, you can write a shell wrapper script like this (let us call it custom_wrapper
):
#!/bin/bash
while true; do
running=`ps ax | grep mysql`;
if [ $running -eq 0 ]; then
python script.py
exit $?
fi
sleep 5
done
Then, set is as executable (chmod +x custom_wrapper
) and modify your cron line as below:
* * * * * custom_wrapper
The custom wrapper script wait for MySQL process to become active, then execute your python script and exits.