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 tests. 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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -