I have a script which before being launched checks via pwd if the path upon launch is something specific (say dir/subdir/script)

current_folder=$(pwd | grep dir/subdir/script)
if [ "$current_folder" == "" ]; then
echo "something bad"

how can this script be launched via crontab? I cannot remove the check with pwd or amend the script content under any circumstance since it's subject to continuous updates that would be replaced

Thanks everyone

1 Answer 1


You can specify several commands, separated by ; or &&, as your cron job, for example:

* * * * * cd /some/path && foo

(This will only run foo if the cd was successful.)

  • that was what I tried which didn't work at first since in the line I had to add some % chars which then came out need to be escaped when used on a crontab line. Thanks for your help, you were right btw
    – funkoolow
    Feb 7, 2017 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.