My Question has 2 parts. Help with both parts is greatly appreciated.
GIVEN INFO: - Lets assume there are 2 Folders, Folder A and Folder B. - Folder A contains many files. - Folder B contains the Shell script (code.sh)
PART A: The script code.sh has to delete all the files in folder A and also afterwards delete the Folder B Including the script code.sh
PART B: Also this has to be scheduled via crontab at some particular time which in itself is not a problem. But after the script has deleted contents of Folder A, it should remove its entry from crontab and then proceed with deleting Folder B as mentioned in PART A.
Is the above possible? If so can someone please tell me how or atleast point me in the right Direction. I'm new to UNIX so any help would be greatly appreciated.
Note: In the whole process, only scheduling the script (code.sh) in crontab should be manual.
crond
and notatd
/at
which is specifically designed to run things once at a specified time?rm -rf FolderA FolderB
. There's no problem with deleting the script itself. On Unix, the contents of a file aren't actually removed until the last process that has it open closes it.