title: how to use firebase cloud function pubsub.schedule?
body: <p>Today, there is new feature of Cloud Functions for Firebase which is running functions on a schedule. So I tried to test the sample code. </p>
  
  <h2>index.js file</h2>
  
  <pre><code>exports.scheduledFunction = functions.pubsub.schedule(‘every 5 minutes’).onRun((context) =&gt; {
    console.log(‘This will be run every 5 minutes!’);
  });
  </code></pre>
  
  <hr>
  
  <p>But when I tried to deploy this, I got the following error message:</p>
  
  <hr>
  
  <pre><code>Error: Error occurred while parsing your function triggers.
  
  TypeError: functions.pubsub.schedule is not a function
  </code></pre>
  
  <hr>
  
  <p>My firebase tools version is <code>6.7</code> (updated today)</p>
  
  <p>What is the solution?</p>
  
  <p>I checked the example git code in here (<a href="https://github.com/firebase/functions-samples/blob/master/delete-unused-accounts-cron/functions/index.js" rel="nofollow noreferrer">https://github.com/firebase/functions-samples/blob/master/delete-unused-accounts-cron/functions/index.js</a>)</p>
  
  <p>But it also cause the same error:</p>
  
  <blockquote>
    <p>functions.pubsub.schedule is not a function</p>
  </blockquote>
  
  <p>Can anyone help me with this problem?</p>
  
  <pre><code>const functions = require('firebase-functions');
  const admin = require('firebase-admin');
  admin.initializeApp();
  
  exports.scheduledFunction = functions.pubsub.schedule('every 5 minutes').onRun((context) =&gt; {
     console.log('This will be run every 5 minutes!');
  });
  </code></pre>