vesta icon indicating copy to clipboard operation
vesta copied to clipboard

backslash in cronjob

Open iceleo-com opened this issue 5 years ago • 4 comments

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

iceleo-com avatar Nov 07 '19 01:11 iceleo-com

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

youradds avatar Dec 24 '19 08:12 youradds

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.

iceleo-com avatar Dec 24 '19 10:12 iceleo-com

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.

youradds avatar Dec 24 '19 12:12 youradds

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.

Skamasle avatar Jan 22 '20 19:01 Skamasle