shell - Can I change the root path to execute a cron task? -


i got shell script( toy-example 1 here):

it creates file on current directory:

#! /usr/bin/sh touch ./toy touch ./doll touch ./boy touch ./kuky touch ./beer 

this shell put on deep path: /somewhere/which/is/in/a/huge/path/tree/maze

but when use crontab execute shell script, no doubt create these files under ~/.

so means if want create these files on /somewhere/which/is/in/a/huge/path/tree/maze, have add long path after every touch command. in case 5 long path. disaster reading.

but if can change root file execute shell, i'll need 1 such path in script or crontab.

is there way so?

change directory:

#!/bin/sh cd /somewhere/which/is/in/a/huge/path/tree/maze ... 

or use variable:

dir="/somewhere/which/is/in/a/huge/path/tree/maze" touch "$dir/toy" ... 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -