vesta
vesta copied to clipboard
backslash in cronjob
Operating System (OS/VERSION):
CentOS 7
VestaCP Version:
lastest
Installed Software (what you got with the installer):
php-fpm, apache, nginx, mysql
Steps to Reproduce:
Edit file: /vesta/web/add/cron/index.php Find: $v_cmd = escapeshellarg($_POST['v_cmd']); Replace with: $v_cmd = escapeshellarg(str_replace('\\', '\\\\', $_POST['v_cmd']));
Edit file: /vesta/web/edit/cron/index.php Find: $v_cmd = escapeshellarg($_POST['v_cmd']); Replace with: $v_cmd = escapeshellarg(str_replace('\\', '\\\\', $_POST['v_cmd']));
Edit file: /vesta/bin/v-list-cron-jobs Find: CMD=$(echo "$CMD" |sed-e 's/"/\"/g' -e "s/%quote%/'/g") Replace with: CMD=$(echo "$CMD" |sed -e 's/\\/\\\\/g' -e 's/"/\"/g' -e "s/%quote%/'/g")
Related Issues/Forum Threads:
When I add a cronjob that has a backslash inside, the backslash is removed by function escapeshellarg(). After adding a cronjob successfully, I cannot get cronjob list because the backslash is not escaped, so PHP cannot decode JSON
Why not create a .sh script with your cron in, and then just invoke that? Bit of a work around but should do the trick
Why not create a .sh script with your cron in, and then just invoke that? Bit of a work around but should do the trick
Thank @youradds for your suggestion. I love to use GUI to manage directly, I'm a lazy man. Each cronjob will have a different run time, so I must create many .sh files for each job. (Login FTP > Create .sh > Add command line > Add cronjob). If I can manage from the control panel, I only need to add a cronjob from the control panel without doing anything else.
Fair enough. You can easily pass in params via a bash script with $1, $2 etc. Thats how I do it with some of mine.
This is alredy discused here some times
For now better fix to this is fun a script with your cron, no any other official solution for now.