linux - check file existence cron job -
i trying write cronjob action if replicationtest.txt not exist , replicationtestseen.txt exist in specific directory. right doing not working. here doing:
0 3 * * 0 [ [ ! -e /dv1/replicationtest/replicationtest.txt ] && [ -e /dv1/replicationtest/replicationtestseen.txt ] ] && echo 'replication passed' | mail -s 'replication test passed' myemail@email.com || echo ' replication failed' | mail -s 'replication failed' myemail@email.com
even when conditions right cron email replication passed still emails replication failed.
you’re mixing test
s. pattern of [ [ ... ] && [ ... ] ]
should not work. see this answer details. if change tests should work:
[[ ! -e ... ]] && [[ -e /dv1/... ]]
test conditions outside of cron before putting them crontab. , make sure of which shell cron set use.
Comments
Post a Comment