When I run the following script from command line I get the full output in /tmp/Fdisk.sh
.
But if I run the same script from cron I get only partial output.
Is the shell skipping some instruction when run from cron?
My Shell script:
SHELL=/bin/sh
LC_NUMERIC=en_US.utf8
/usr/bin/printf "\nm\np\nl\nq" | fdisk /dev/mmcblk0
CRON entry:
* * * * * /home/WiMi/tryFdisk.sh >> /tmp/Fdisk.txt
Output, when run from cron:
cat /tmp/Fdisk.txt
Disk /dev/mmcblk0: 63.8 GB, 63864569856 bytes
4 heads, 16 sectors/track, 1948992 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 33 1948992 62366720 83 Linux
The main concern here is the missing of commands passed to fdisk in a non interactive way.
I have passed commands and couple of them got skipped.
m - display help screen - skipped p - print current partition table - executed l - list know partition types - skipped q - quit - executed
If I run the same script from command line, all of them gets executed and the output is seen on the /tmp/Fdisk.txt file.