Skip to content

Instantly share code, notes, and snippets.

@ybagheri
Last active January 2, 2018 10:07
Show Gist options
  • Select an option

  • Save ybagheri/e17874e53b33abb28649a60ba63223b7 to your computer and use it in GitHub Desktop.

Select an option

Save ybagheri/e17874e53b33abb28649a60ba63223b7 to your computer and use it in GitHub Desktop.
Cron job check mysql for run php script and run every 5 second
# check mysql for run php script
if [ $(mysql -u MYSQL_USER -pMYSQL_PASSWORD -Bse "SELECT flag FROM DATABASE_NAME.TABLE_NAME where id=1") == "1" ]; then
curl --silent "http://example.com" >/dev/null 2>&1
fi
# Cronjob every 5 second
# first create script
vi /path/to/foo.sh
# copy script, run curl 11 times, press `a` and paste.
curl --silent "http://example.com" >/dev/null 2>&1
sleep 5
curl --silent "http://example.com" >/dev/null 2>&1
sleep 5
curl --silent "http://example.com" >/dev/null 2>&1
sleep 5
curl --silent "http://example.com" >/dev/null 2>&1
sleep 5
curl --silent "http://example.com" >/dev/null 2>&1
sleep 5
curl --silent "http://example.com" >/dev/null 2>&1
sleep 5
curl --silent "http://example.com" >/dev/null 2>&1
sleep 5
curl --silent "http://example.com" >/dev/null 2>&1
sleep 5
curl --silent "http://example.com" >/dev/null 2>&1
sleep 5
curl --silent "http://example.com" >/dev/null 2>&1
sleep 5
curl --silent "http://example.com" >/dev/null 2>&1
sleep 5
# press scape, :wq
# VERY IMPORTANT : add 755 to this .sh file
chmod 755 /path/to/foo.sh
# create crontab
crontab -e
# add to file and save
* * * * * /path/to/foo.sh
# check your jobs
crontab -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment