-1

I have tar command in crontab

52 9 * * * sudo tar czpf /path/tar.gz  /data

But when i grep ps output then i get this

john  19496  0.0  0.0   4508   840 ?        Ss   09:52   0:00 /bin/sh -c sudo tar czpf /A_BACKUPS/data-full-`date "+%d-%m-%Y-%H:%M"`.tar.gz /data  > /home/john/logs/cron__TAR__DATA-`date "+%d-%m-%Y-%H:%M"`.txt 2>&1
root     19499  0.0  0.0  48576  3532 ?        S    09:52   0:00 sudo tar czpf /A_BACKUPS/data-full-07-02-2017-09:52.tar.gz /data
root     19500  3.3  0.0  29572  2892 ?        S    09:52   0:04 tar czpf /A_BACKUPS/data-full-07-02-2017-09:52.tar.gz /data
john  19528  0.0  0.0  16572  2136 pts/0    S+   09:54   0:00 grep --color=auto A_BA

Why there are 3 diff processes for that

1 Answers1

1

Cron command lines can be complex shell commands, so they are executed using shells. Hence sh -c .... Then you have the actual commands executed by the command line, in its own processes - sudo .... Then you have the command that sudo started, tar. And finally you have the grep, because you used ps | grep.

muru
  • 197,895
  • 55
  • 485
  • 740