crontab using shell script to sync files.

Hi,

I developed one shell script where it will sync the files using perforce,

#!/bin/bash
TERM=linux
export TERM

clear
echo ""
$PATH
echo ""
cd /u/userk/p4/p4_client/TES_DATE
echo ""

echo "Sync p4 "
p4 sync

echo "Executing for second time "
p4 -u userk -p p4net:161 -c userk:p4_client sync

this script executes well when i execute from my directory, i want this script to run every 15 min, and sync the latest files using perforce(p4) so i am using cronjob to achive this, my crontab files goes like this

MAILTO=userk@abensdes.com
*/15 * * * * /u/userk/auto_sync_p4.sh

this cronjob is executed, but files are not synced , and i am getting

p4 command not found.

Please let me know how to execute p4 command from cronjob.

Regards,
asak

Perhaps "p4" command is not in your PATH.
use the fully qualified path for p4. like .

/some/path/p4 sync

Hi Clx,

i tried by giving complete path getting like this,

/u/userk/p4/p4_client/p4: No such file or directory

and one more thing, i am going into the directory where p4 is present using cd and then i
am executing p4 sync.

echo ""
cd /u/userk/p4/p4_client/TES_DATE
echo ""

echo "Sync p4 "
p4 sync

Regards,
asak

 
cd /u/userk/p4/p4_client/TES_DATE
echo ""

echo "Sync p4 "
p4 sync

 
i tried by giving complete path getting like this,


Code:
/u/userk/p4/p4_client/p4: No such file or directory

Hi itkamaraj,

Giving complete path also gives the same error,

/u/userk/p4/p4_client/TES_DATE/ p4: No such file or directory

Regards,
asak

still, i see the space in between the DATE/ and p4

 
/u/userk/p4/p4_client/TES_DATE/ p4

I tried with space and also without space, p4 is a command so i tried giving with space , still same i am getting, the script runs fine when i execute from my home directory, but when i execute from cronjob, it shows p4 command not found or No such file or directory

can you execute the below command and confirm, whether p4 is present.

If it is not there, then check where is your p4 command and use that absolute path

ls -l /u/userk/p4/p4_client/TES_DATE/p4
1 Like

Hi itkamaraj,

I tried

$ which p4
/usr/software/bin/p4

And gave absolute path as told.
it is working now.

(b4p4: using $P4CLIENT userk:p4_client; $P4PORT p4netapp:16)
File(s) up-to-date.

Thanks ,
asak