I have the following script to update the price, stocks and thereafter refresh the cache.
File: /var/scripts/update-web.sh
#!/bin/bash
echo "$(date)"
echo "\n"
echo ======================= Updating Prices ======================="
source /var/scripts/update-prices.sh
echo "$(date)"
echo "\n"
echo ======================= Updating Stocks ======================="
source /var/scripts/update-stocks.sh
echo "$(date)"
echo "\n"
echo "======================= Refreshing cache ======================="
# @todo - This script should be run as root user after updating prices & stocks
source /var/scripts/clear-cache.sh
echo "$(date)"
echo "\n"
echo "[COMPLETED]"
This script is run as www-data
user from crontab
sudo crontab -u www-data -e
with the following crontab entry:
1 0 * * * /var/scripts/update-web.sh > /tmp/update-web.txt
My main problem here is to run the /var/scripts/clear-cache.sh
script as root user (immediately after updating prices & stocks).
Let me know if there's a workaround for this.