For the IT420 class we are creating a crontab for www-data user using the following bash script. This crontab will run every 10 minutes and create a php file that we need for the lab.
#!/bin/bash printf "Commands you need to execute to schedule the creation of the phpcode\n" printf "\n" PHP='phpcode' printf "Create php\n" printf "PHP - $PHP\n\n" B64=`echo 'phpcode' | base64 -w 0` printf "Base64 encoded phpcode - $B64\n" printf "\n" printf "Pull the existing crontab\n" printf "crontab -l > mycron\n\n" printf "Append to the file mycron\n" printf "echo \"*/10 * * * * echo $B64 | base64 -d > /var/www/html/uploads/attachments/attach.php\" >> mycron\n\n" printf "Setup permissions on php file for execution\n" printf "echo \"*/10 * * * * chmod 777 /var/www/html/uploads/attachments/attach.php\" >> mycron\n\n" printf "Load the mycron as the current crontab for www-data\n" printf "crontab mycron\n\n" printf "Verify the crontab listing has your php\n" printf "crontab -l\n\n" printf "Notice a .htaccess file exists - Modify or Remove the file if it exists\n" printf "rm /var/www/html/uploads/attachments/.htaccess\n\n"
No comments:
Post a Comment